Java – implement ` hashcode() for very simple classes`

I have a very simple class with only one field member (such as string) Implementing hashcode () can simply return fieldmember Hashcode()? Or should I manipulate the hash code of this field in some way? Besides, if I should manipulate it, why?

Solution

If fieldmember is the only good way to identify objects, I would say yes

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>