learning java identityHashCode

        var S1 = new String("aaaaa");
        System.out.println("SI hasCode: " + S1.hashCode());
        System.out.println("S1 identity Hash Code:" + System.identityHashCode(S1));

        var S2 = new String("aaaaa");
        System.out.println("S2 hasCode: " + S2.hashCode());
        System.out.println("S2 identity Hash Code:" + System.identityHashCode(S2));

output:

SI hasCode: 92567585
S1 identity Hash Code:780237624
S2 hasCode: 92567585
S2 identity Hash Code:205797316

  

posted @ 2019-07-25 14:39  嵌入式实操  阅读(140)  评论(0编辑  收藏  举报