Can I only implement equals() but not hashCode() if I only need to compare objects and not yet plan to put the objects into any hash based containers?
Seems all Jav
Can I only implement equals() but not hashCode()?
Yes You can . Because they are just to method from the parent class Object
, So it actually your choice to implement or not to (together or individual.)
All Java bibles say these two MUST be implemented together.
If you are not using anything related to hashcode
(as you said hash based container) it not a MUST
, But it is a good practice to implement them together to avoid any unexpected circumstances.