字符串和list的转化非常方便,如下:
String[] strArray = { “array-a”, “array-b” };
List strList = new ArrayList<>(strArray.length);
int型这么做就会报错:error: no suitable method found for toArray(int[])
必须通过赋值来转化,实例如下:
List list=new ArrayList();
int [] arr = new int[list.size()];
for(int k=0;k<arr.length;k++)
{
arr[k]=list.get(k);
}
return arr;