Questions tagged «equals»

引用Java equals方法,指示某个对象是否“等于”该对象。

10
在子类中覆盖equals()和hashCode()……考虑到超级字段
关于如何考虑超字段的子类中的Override equals()&hashCode()in,是否有特定规则?知道有很多参数:超字段是private / public,有/没有getter ... 例如,Netbeans生成的equals()和hashCode()不会考虑超级字段...和 new HomoSapiens("M", "80", "1.80", "Cammeron", "VeryHot").equals( new HomoSapiens("F", "50", "1.50", "Cammeron", "VeryHot")) 将返回true :( public class Hominidae { public String gender; public String weight; public String height; public Hominidae(String gender, String weight, String height) { this.gender = gender; this.weight = weight; this.height = height; …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.