java打印数组的方法
1. 转型打印
System.out.println(Arrays.toString(arr));
System.out.println(Arrays.asList(arr));
System.out.println(Arrays.deepToString(arr));
2. 流循环打印
Arrays.asList(arr).stream().forEach(s -> System.out.println(s));
3. 对象和数组循环打印
for(int n: arr){ System.out.println(n+", "); } for (int i = 0; i < arr.length; i++) { System.out.print(arr[i] + ", "); }