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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -