JavaTuples setKey() method
The setKey() method in org.javatuples is used to set the key of the KeyValue Class object. This method can be used with only KeyValue class object of javatuples library. It returns another KeyValueClassObject with the Key as the element passed as the parameter, and the value from the previous KeyValueClassObject.
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.
public <X> KeyValue<X, B> setKey(X key)
KeyValue<X, B> KeyValueClassObject = KeyValue.setKey(X key)
Return Value: This method returns another KeyValueClassObject with the Key as the element passed as the parameter, and the value from the previous KeyValueClassObject.
Below programs illustrate the various ways to use setKey() method:
[GeeksforGeeks, A computer science portal]