DESKTOP-95VI5AL_20200831王盼盼

日志

1、问题

##### 1.1

        int[] a = { 1  , 3 , 5 , 7 , 9 };
        int[] b = { 1  , 3 , 5 , 7 , 9 };
        System.out.println(System.identityHashCode(a));//1562557367
        System.out.println(System.identityHashCode(b));//1101288798
        //虽然new省略了,但数组的实例化还是完成了。
        System.out.println( a == b ); // false


        // 所有数组对象对应的类型都没有重写equals(Object)方法

问题     // 理解: a.equals( b ) 与 Arrays.equals( a , b ) 的区别

        System.out.println( a.equals( b ) ); // false
        System.out.println( Arrays.equals( a , b ) ); // true

    public boolean equals(Object obj) {
        return (this == obj);
    }
    //相当于System.identityHashCode()值的比较

    @HotSpotIntrinsicCandidate
    public static boolean equals(byte[] a, byte[] a2) {
        if (a==a2)
            return true;
        if (a==null || a2==null)
            return false;

        int length = a.length;
        if (a2.length != length)
            return false;

        return ArraysSupport.mismatch(a, a2, length) < 0;
    }
    //数组内部数组元素的比较
1.2

2、吐槽

累了