Java equal and hashCode with non primitive types -
I have a class with some non-primitive members.
class relations {string name; From role role; Role role; } Role of the class (rolltype role type); String description; } Class RoleType {String typeName; String description;
The two relationships are the same, when
- the name is equal
- the role type (unique type name identification) is the same as the role How to
equal
andhash code
for members (role and role)
class relationship
Write Tried with Netbeans, it displays only 3 fields ( name
, roleFrom
and roleTo
) because that is because someone Primitive types should not be used in RAP and roll to (rollotype -> typename).
Thank you.
When is implemented, hash code ()
and With the non-primitive types of fields, it is believed that this type is also
hash code ()
and equals ()
correctly Go to other classes and apply hashhead ()
and equals ()
(again using the Auto-Generating Features of your IDE).
Comments
Post a Comment