java - hashCode can be the same for different instances of an inner class? -
i have custom swingworker inner class. found several times hashcode same different instances of it. why that? normal?
edit:
the inner class have subclass of swingworker class.
hash codes not need different different objects. requirement must same equal objects.
if concern swingworker inner classes produce identical hash codes, override hashcode method in inner class provide hash codes suit needs better. of course need override equals supply matching logic both methods:
final int workerid = 123; swingworker<string,object> myworker = new swingworker<string,object> { @override public string doinbackground() { ... } @override protected void done() { ... } @override public int hashcode() { return workerid; } @override public boolean equals(object other) { return other == this; } }
Comments
Post a Comment