Arrays.deepToString()与Arrays.toString()的区别
程序员文章站
2022-03-11 22:05:01
...
Arrays.deepToString()与Arrays.toString()的区别
Arrays.deepToString()主要用于数组中还有数组的情况,而Arrays.toString()则相反,对于Arrays.toString()而言,当数组中有数组时,不会打印出数组中的内容,只会以地址的形式打印出来。
-
示例:
package com.oovever.hutool.util; import java.util.Arrays; /** * @Author OovEver * @Date 2017/12/24 17:31 */ public class test { public static void main(String[] args) { int a[] = {1, 2, 3}; System.out.println(Arrays.toString(a)); int b[][] = {{1, 2, 3}, {4, 5, 6}}; System.out.println(Arrays.toString(b)); System.out.println(Arrays.deepToString(b)); } }
-
结果
[1, 2, 3]
[[[email protected], [[email protected]]
[[1, 2, 3], [4, 5, 6]]
下一篇: docker3-compose多容器应用