import java.util.*;
public class Main {
public static void main
(String[] args
) { Data d = new Data(1,"foo");
set.add(d);
set.add(new Data(2,"bar"));
System.
out.
println(set.
contains(d
)); d.field1 = 2;
System.
out.
println(set.
contains(d
)); }
public static class Data {
int field1;
field1 = f1;
field2 = f2;
}
public int hashCode() {
return field2.hashCode() + field1;
}
public boolean equals
(Object o
) { if(!(o instanceof Data)) return false;
Data od = (Data)o;
return od.field1 == this.field1 && od.field2.equals(this.field2);
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwoKcHVibGljIGNsYXNzIE1haW4gewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHsKCQlTZXQgc2V0ID0gbmV3IEhhc2hTZXQoKTsKCQlEYXRhIGQgPSBuZXcgRGF0YSgxLCJmb28iKTsKCQlzZXQuYWRkKGQpOwoJCXNldC5hZGQobmV3IERhdGEoMiwiYmFyIikpOwoJCVN5c3RlbS5vdXQucHJpbnRsbihzZXQuY29udGFpbnMoZCkpOwoJCWQuZmllbGQxID0gMjsKCQlTeXN0ZW0ub3V0LnByaW50bG4oc2V0LmNvbnRhaW5zKGQpKTsKCX0KCQoJcHVibGljIHN0YXRpYyBjbGFzcyBEYXRhIHsKCQlpbnQgZmllbGQxOwoJCVN0cmluZyBmaWVsZDI7CgkJCgkJRGF0YShpbnQgZjEsIFN0cmluZyBmMikgewoJCQlmaWVsZDEgPSBmMTsKCQkJZmllbGQyID0gZjI7CgkJfQoJCQoJCXB1YmxpYyBpbnQgaGFzaENvZGUoKSB7CgkJCXJldHVybiBmaWVsZDIuaGFzaENvZGUoKSArIGZpZWxkMTsKCQl9CgkJCgkJcHVibGljIGJvb2xlYW4gZXF1YWxzKE9iamVjdCBvKSB7CgkJCWlmKCEobyBpbnN0YW5jZW9mIERhdGEpKSByZXR1cm4gZmFsc2U7CgkJCURhdGEgb2QgPSAoRGF0YSlvOwoJCQlyZXR1cm4gb2QuZmllbGQxID09IHRoaXMuZmllbGQxICYmIG9kLmZpZWxkMi5lcXVhbHModGhpcy5maWVsZDIpOwoKCQl9Cgl9Cn0=