Код: Выделить всё
public class UserDefinedName {
private final String first, last;
public UserDefinedName(String first, String last) {
this.first = first;
this.last = last;
}
public boolean equals(Object o) {
if (!(o instanceof UserDefinedName))
return false;
UserDefinedName n = (UserDefinedName) o;
return n.first.equals(first) && n.last.equals(last);
}
public static void main(String[] args) {
Set s = new HashSet();
s.add(new UserDefinedName("Carballo", "Videl"));
System.out.println(s.contains(new UserDefinedName("Carballo", "Videl")));
}
}
Подробнее здесь: https://stackoverflow.com/questions/171 ... tion-works