对于一个一维数组,他在转换成字符串的时候应该调用Arrays.toString();
对于一个多维数组,他在转换成字符串的时候应该调用Arrays.deepToString();
实例:
package study; import java.util.Arrays; public class de {
public static void main(String[] args) {
int[] a={1,2,3,3,3,4,44,4,5,5,4,5,6,7};
System.out.println(Arrays.toString(a));
int[][] a1={{3,3,3,4,44,4},{5,5,4,5,6,7}};
System.out.println(Arrays.deepToString(a1));
}
}
结果:
[1, 2, 3, 3, 3, 4, 44, 4, 5, 5, 4, 5, 6, 7]
[[3, 3, 3, 4, 44, 4], [5, 5, 4, 5, 6, 7]]