Java中String[]类型与ArrayList类型之间转换
- List转为String[]
List list = new ArrayList(); String[] stringArray = new String[2]; list.toArray(stringArray); //String str[] = list.toArray(new String[]{});
- String[]转为List
String[] stringArray = new String[2]; List list = java.util.Arrays.asList(stringArray);
- remove() on List created by Arrays.asList() throws UnsupportedOperationException
直接使用Arrays.asList(la)转成List<> 使用remove时会报错,所以可以有一下用法: List<String> c = new ArrayList<>(Arrays.asList(la));