打印java数组最简单的方式
简单的数组
String[] array = new String[] {"John", "Mary", "Bob"};
System.out.println(java.util.Arrays.toString(array));
//输出 [John, Mary, Bob]
嵌套数组
String[][] deepArray = new String[][] {{"John", "Mary"}, {"Alice", "Bob"}};
System.out.println(java.util.Arrays.toString(deepArray));
// 输出 [[Ljava.lang.String;@106d69c, [Ljava.lang.String;@52e922]
System.out.println(java.util.Arrays.deepToString(deepArray));
//输出 [[John, Mary], [Alice, Bob]]
Loading...