javaSE
学习进行时!
备战
展开
-
hashCode()和System.identityHashCode的区别
hashCode是根据对象的地址生成的哈希值,只要判断出两个对象的hashCode不一致,就知道两个对象不是同一个 我运行的代码 Student s1 = new Student(18,"Kang"); Student s2 = s1; System.out.println(s1.hashCode()); System.out.println(s2.hashCode()); System.out.println(System.identityHashCode(s1原创 2022-01-15 22:40:43 · 502 阅读 · 0 评论 -
java的hashcode,new和地址引用小插曲
Student s1 = new Student(18,"Kang"); Student s2 = new Student(); s2=s1; System.out.println(s1.hashCode()); System.out.println(s2.hashCode()); s2.setAge(22); System.out.println(s1); System.out....原创 2022-01-15 21:08:35 · 141 阅读 · 0 评论