import java.util.HashSet; class Dolgozo { String nev; int kor; double fiz; Dolgozo(String nev, int kor, double fiz) { this.nev = nev; this.kor = kor; this.fiz = fiz; } @Override public boolean equals(Object o) { if(this == o) return true; Dolgozo dolgozo = (Dolgozo) o; if(!dolgozo.nev.equals(this.nev)) return false; if(dolgozo.kor!=(this.kor)) return false; if(dolgozo.fiz!=(this.fiz)) return false; return true; } @Override public int hashCode() { int nevHash = this.nev.hashCode(); int korHash = this.kor; int fizHash = (new Double(this.fiz)).hashCode(); int res = nevHash + korHash + fizHash; return res; } } class Program01 { public static void main(String args[]) { HashSet h = new HashSet(); h.add(new Dolgozo("Nagy József", 35, 350000)); h.add(new Dolgozo("Nagy József", 35, 350000)); System.out.println(h.contains(new Dolgozo("Nagy József", 35, 350000))); System.out.println(h.size()); } }