/* * Name.java * * Created on 27. únor 2004, 15:35 */ package examples; import java.util.*; /** * * @author honza */ public class Name { private String first, last; /** Creates a new instance of Name */ public Name(String first, String last) { if (first == null || last == null) throw new NullPointerException(); this.first = first; this.last = last; } public boolean equals(Object o) { Name other = (Name)o; return first.equals(other.first) && last.equals(other.last); } /** * @param args the command line arguments */ public static void main(String[] args) { Set s = new HashSet(); s.add(new Name("Mickey", "Mouse")); System.out.println(s.contains(new Name("Mickey", "Mouse"))); } }