For HashMap, would implementing hashCode() for the value help if I only search by key?

No, you only need to implement hashCode and equals for the key type If you're just storing it as a value, implementing those methods will make no difference (to performance or correctness).

No, you only need to implement hashCode and equals for the key type. If you're just storing it as a value, implementing those methods will make no difference (to performance or correctness).

I don't think you need to worry about implementing the 2 methods if you are jut using String as the key. You however need to override them both if you are planning to use Class A as the key.

You only need to support hashCode and equals for keys in a HashMap. Since the key is a string, and not an A, no need to implement those - they will not get used.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions