日期:2014-05-20 浏览次数:20717 次
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; FileTest other = (FileTest) obj; if (idCard == null) { if (other.idCard != null) return false; } else if (!idCard.equals(other.idCard)) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; return true; } public static void main(String[] args) { Person p1 = new Person("1001", "刘德福"); Person p2 = new Person("1001", "刘德华"); System.out.println(p1.equals(p2)); ; }