Effective Java 第三章笔记
作者:
ktdroid | 来源:发表于
2016-07-24 16:02 被阅读0次
对于所有对象都通用的方法
1. 覆盖 equals 时请遵守通用约定
x != null
x.equals(x) == true
x != null && y != null
when x.equals(y) == true then y.equals(x) == true
x != null && y != null && z != null
when x.equals(y) == true && y.equals(z) == true then x.equals(z) == true
x != null
x.equals(null) == false
2. 覆盖 equals 时总要覆盖 hashCode
3. 始终要覆盖 toString
4. 谨慎地覆盖 clone
5. 考虑实现 Comparable 接口
本文标题:Effective Java 第三章笔记
本文链接:https://www.haomeiwen.com/subject/oezwjttx.html
网友评论