java一维和多维数组的输出
作者:互联网
`public class A {
public static void main(String[] args) {
int[] arrays1 = new int[]{1, 2, 3, 4};
// 1.for循环
for (int i = 0; i < arrays1.length; i++) {
System.out.println(arrays1[i]);
}
// 2.foreach
for(int i : arrays1){
System.out.println(i);
}
// 3.Arrays工具类,参数为多维数组会输出地址
System.out.println(Arrays.toString(arrays1));
// 4.Arrays工具类,可用于多维数组
int[][] arrays2 = new int[][]{{1, 2}, {3, 4}};
System.out.println(Arrays.deepToString(arrays2));
}
}
`
标签:java,int,System,Arrays,维和,多维,println,arrays1,out 来源: https://www.cnblogs.com/itjone/p/14788358.html