The getKey() method in org.javatuples is used to fetch the key from the TupleClassObject from the KeyValue Class. This method can be used with only KeyValue class object of javatuples library. It returns a Key which is the element present at the index 0 of the KeyValueClassObject. The returned Key is ensures the type-safety.
public A getKey()
KeyValue<A, B> KeyValueClassObject = KeyValue.with(A a, B b); A val = KeyValueClassObject.getKey()
Return Value: This method returns a Key which is the element present at the index 0 of the KeyValueClassObject.
Below programs illustrate the various ways to use getKey() method:
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. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.