|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Tom Reilly wrote:The HashMap.get() method first checks whether the key you are looking for is == before calling the equals() method. Since the d1 object you are looking for is in the HashMap then the == finds the object so there is no need to call equals(). You can verify this by adding System.out.println() in your equals() and hashCode() methods.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Tom Reilly wrote:The HashMap.get() method first checks whether the key you are looking for is == before calling the equals() method. Since the d1 object you are looking for is in the HashMap then the == finds the object so there is no need to call equals(). You can verify this by adding System.out.println() in your equals() and hashCode() methods.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
I didn't see a question.Could you please tell me the answer for my above post codes snips?
Tom Reilly wrote:
I didn't see a question.Could you please tell me the answer for my above post codes snips?