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

  1. the name is equal
  2. the role type (unique type name identification) is the same as the role How to equal and hash 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

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -