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