changchangjie / changchangjie.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Java基础-equals与hashcode | Changjie's blog

changchangjie opened this issue · comments

https://changjie.me/2018/10/09/equals%E4%B8%8Ehashcode/#more

equals方法euqals()作为Object的方法,用于判断两个对象是否相等123public boolean equals(Object obj) { return (this == obj);} 很明显是对两个对象的地址值进行的比较(即比较引用是否相同)。像String 、Math、Integer、Double等这些封装类已经将其重写了,比较的是内容