import java.util.*;
import java.lang.*;
class Main
{
static class Person {
public String getFirst
() {return first
;} public String getLast
() {return last
;} first = f;
last = l;
}
return first+" "+last;
}
}
{
List<Person> people = new ArrayList<Person>();
people.add(new Person("John", "Smith"));
people.add(new Person("John", "Scott"));
people.add(new Person("Jack", "First"));
people.add(new Person("John", "Walker"));
people.add(new Person("Jack", "Black"));
Set<Object> seen = new HashSet<Object>();
for (Person p : people) {
final Person thisPerson = p;
class Wrap {
public int hashCode() { return thisPerson.getFirst().hashCode(); }
public boolean equals
(Object o
) { Wrap other = (Wrap)o;
return other.wrapped().getFirst().equals(thisPerson.getFirst());
}
public Person wrapped() { return thisPerson; }
};
Wrap wrap = new Wrap();
if (seen.add(wrap)) {
System.
out.
println(p
+ " is new"); } else {
System.
out.
println(p
+ " is a duplicate"); }
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CgpjbGFzcyBNYWluCnsKCXN0YXRpYyBjbGFzcyBQZXJzb24gewoJCXByaXZhdGUgU3RyaW5nIGZpcnN0OwoJCXByaXZhdGUgU3RyaW5nIGxhc3Q7CgkJcHVibGljIFN0cmluZyBnZXRGaXJzdCgpIHtyZXR1cm4gZmlyc3Q7fQoJCXB1YmxpYyBTdHJpbmcgZ2V0TGFzdCgpIHtyZXR1cm4gbGFzdDt9CgkJcHVibGljIFBlcnNvbihTdHJpbmcgZiwgU3RyaW5nIGwpIHsKCQkJZmlyc3QgPSBmOwoJCQlsYXN0ID0gbDsKCQl9CgkJcHVibGljIFN0cmluZyB0b1N0cmluZygpIHsKCQkJcmV0dXJuIGZpcnN0KyIgIitsYXN0OwoJCX0KCX0KCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCUxpc3Q8UGVyc29uPiBwZW9wbGUgPSBuZXcgQXJyYXlMaXN0PFBlcnNvbj4oKTsKCQlwZW9wbGU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