0%

Java List与数组之间的转换

1. 数组转换为List

1
2
String[] arr = new String[] {"str1", "str2"};
List<String> list = Arrays.asList(arr);

2 .List转换为数组

1
2
3
4
5
List<String> list = new ArrayList<String>();
list.add("str1");
list.add("str2");
int size = list.size();
String[] arr = list.toArray(new String[size]);
欣赏此文?求鼓励,求支持!
Title - Artist
0:00