Difference between hashcode and identityHashCode in JAVA
9963 Views
hashCode() method
identifyHashCode() method
hashCode method is a method of Object class.
identifyHashCode method is a method of System class.
Object.hashCode() to get the hash code of the object. This method is basically existing in all objects. Because Object class is the root class of all Classes in JAVA.
System.identifyHashCode(Object) to get the hash code of the given object. It returns the same integer of hashCode() method.
If class is overritten the hashCode() method then this System.identifyHashCode() method is to check.
Notes.
Generally when printing java object without toString method in a Class. Getting com.google.Gson@10385c1. This number(10385c1) is hex decimal figure of hash code. It means the address reference of the object with the Class Name. Integer.toHexString(obj.hashCode());
Returns 10385c1 for the same object. so package.Class_name@address_in_hex it means.