Not able to compare objects in Java string getting appended to classname -
i comparing 2 objects in java , have implemented equals , hashcode.
though objects equal comparison returns false.
i found in equals implementation it's printing class of 2 objects different although same.
for 1 prints: com.salebuild.model.technologyproduct
while other prints: com.salebuild.model.technologyproduct_$$_javassist_71
so fails in condition in equals method:
if (getclass() != obj.getclass()) { return false; }
unable find why it's appending string: _$$_javassist_71
how can overcome this? suggest?
use instanceof
check if both objects of same class.
here code eclipse offers check object equality:
public boolean equals(object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof ldapuserdetails)) //check class here return false; // check fields equality here }
Comments
Post a Comment