hashCode and identityHashCode in Java #java #javaprogramming #shorts



hashCode and identityHashCode in Java #java #javaprogramming #shorts

hashCode and identityHashCode in Java #java #javaprogramming #shorts

The Hashcodes of two Strings are the same if the strings are equal.

We cannot use the hashcode if we need a unique identifier for each object in any application.

You will need to use the identityHashCode instead. identityHashCode is returned by a System call.

Even though we have the same content, the two strings have two different identityHashcodes, while their normal HashCodes are the same.

Dr. Shahriar Hossain and Dr. Monika Akbar
https://computing4all.com