The hashCode() method in org.javatuples method returns the hash code for the JavaTuple class object. The hashcode is always the same if the object doesn’t change. Hashcode is a unique code generated by the JVM at time of object creation. It can be used to perform some operation on hashing related algorithm like hashtable, hashmap etc. An object can also be searched with this unique code.
public final int hashCode()
int code = TupleClassObject.hashCode()
Here TupleClassObject represents the JavaTuple Class used like Unit, Quartet, Decade, KeyValue, etc.
Returns: It returns an integer value which represents hashCode value for this TupleClassObject.
Below program illustrates hashcode() method of TupleClassObject:
Program 1: Get the hash code of a Quartet Class object.
Program 2: Get the hash code of a LabelValue Class object.
Note: Similarly, it can be used with any other JavaTuple Class.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.