java - Implementing `hashCode()` for very simple classes -


I have a very simple class with only one field member (for example string). Is it OK to hashode () just return fieldMember.hashCode () ? Or should I manipulate the hash code of the field? Besides, if I should manipulate it, then why is it so?

If the field is a very good way to identify the object, I say yes.


Comments