/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
static class Test {
this.name = name;
}
public String GetName
() { return name
; } public void SetName
(String name
) { this.
name = name
; }
@Override
public boolean equals
(Object o
) { if (o == null) return false;
if (o == this) return true;
if (!(o instanceof Test)) {
return (o
instanceof String) && (name.
equals(o
)); }
Test t = (Test)o;
return name.equals(t.GetName());
}
@Override
public int hashCode() {
return name.hashCode();
}
@Override
return name;
}
}
{
Test a = new Test(x);
Test b = new Test(x);
System.
out.
println(a.
equals(b
)); System.
out.
println(a.
equals(x
));
List<Test> test = new ArrayList<Test>();
test.add(a);
test.add(b);
System.
out.
println(test.
contains(new Test
(x
)));
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXN0YXRpYyBjbGFzcyBUZXN0IHsKCQoJCXByaXZhdGUgU3RyaW5nIG5hbWU7CgkJCgkJcHVibGljIFRlc3QoU3RyaW5nIG5hbWUpIHsKCQkJdGhpcy5uYW1lID0gbmFtZTsKCQl9CgkJCgkgICAgcHVibGljIFN0cmluZyBHZXROYW1lKCkgeyByZXR1cm4gbmFtZTsgfQoJICAgIHB1YmxpYyB2b2lkIFNldE5hbWUoU3RyaW5nIG5hbWUpIHsgdGhpcy5uYW1lID0gbmFtZTsgfQoJCQoJCUBPdmVycmlkZQoJICAgIHB1YmxpYyBib29sZWFuIGVxdWFscyhPYmplY3QgbykgewoJICAgIAlpZiAobyA9PSBudWxsKSByZXR1cm4gZmFsc2U7CgkgICAgICAgIGlmI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