+1 vote
in JAVA by
What is a.hashCode() used for? How is it related to a.equals(b)?

1 Answer

0 votes
by

hashCode() method returns an int hash value corresponding to an object. It's used in hash based collection classes e.g Hashtable, HashMap, LinkedHashMap and so on. It's very tightly related to equals() method. According to Java specification, two objects which are equal to each other using equals() method must have same hash code.

Related questions

+2 votes
asked Jan 24, 2020 in JAVA by rahuljain1
0 votes
asked Oct 24, 2020 in JAVA by sharadyadav1986
...