DESKTOP-5NB63LS_20200831-潘振林

问题

1、toString()和deepToString()

Arrays.toString(a)可用于得到一维数组中元素的字符串形式;在遇到数组中还有数组时,只能得到内层数组对应的hashCode值

Arrays.deepToString(a)可用于得到多维数组中深层数组中对应元素的字符串形式

Dog dog1=new Dog("大狗");
Dog dog2=new Dog("二狗");
Dog dog3=new Dog("三狗");
Dog dog4=new Dog("四狗");
Dog[][] a= {{dog1,dog2},
            {dog3,dog4}
            };
System.out.println(Arrays.toString(a));
//结果[[Lcom.pan.Comparing.Dog;@7637f22, [Lcom.pan.Comparing.Dog;@4926097b]
System.out.println(Arrays.deepToString(a));
//结果[[[name=大狗], [name=二狗]], [[name=三狗], [name=四狗]]]
        

2、 hashCode()和deepHashCode()

上面的可以理解,但是Arrays.deepHashCode(a)是啥意思,解释不通啊

System.out.println(Arrays.hashCode(a));
System.out.println(Arrays.deepHashCode(a));

心得

有些方法用起来总感觉怪怪的,写这些东西的人脑子瓦特了