ArrayList->Object[]
List<String> list=new ArrayList<> ();
list.add("理智");
list.add("ikun");
list.add("小黑子");
Object[] array=list.toArray();//(1)
String[] array=(String[])list.toArray()
String[] array=new Sting[list.size()];//(2)
list.toArray(array);
Object[]-> ArrayList
int array[] = {1,2,3,4,5,};
List<Integer> list = new ArrayList<>();
for (int a: array) {
list.add(a);
}
for(int i=0;i<array.length,i++){
list.add(array[i]);
}
System.out.println(list);
int arr[]={1,2};//基本数据类型的数组会失败,打印地址
list list=Arrays.aslist(arrs);
System.out.println(list);//[[I@1b6d3586]
Integer[] arr=new Integer[]{1,2};
List<Integer> list= Arrays.asList(arr);
System.out.println(list);//[1, 2]
打印数组
System.out.println(Arrays.toString(数组对象))