一:
int[] arr1 = new int[1]; //必须初始化数量,还有不初始化数字的
arr1[0] = 1;
System.out.println("array1: " + Arrays.toString(arr1));
二:
int[] arr2 = {1,2};
System.out.println("array2: " + Arrays.toString(arr2));
三:
int[] arr3 = new int[]{1,2}; //这个一定不能初始化数字
System.out.println("array3: " + Arrays.toString(arr3));
输出结果:
array1: [1]
array2: [1, 2]
array3: [1, 2]
注:Integer[] 跟int[] 不同,不能转换
标签:初始化,int,System,Arrays,toString,out From: https://www.cnblogs.com/dongdges/p/16848049.html