VOOZH about

URL: https://www.geeksforgeeks.org/java/java-tuples-setlabel-method/

⇱ JavaTuples setLabel() method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaTuples setLabel() method

Last Updated : 11 Jul, 2025
The setLabel() method in org.javatuples is used to set the label of the LabelValue Class object. This method can be used with only LabelValue class object of javatuples library. It returns another LabelValueClassObject with the Label as the element passed as the parameter, and the value from the previous LabelValueClassObject. Method Declaration:
public <X> LabelValue<X, B> setLabel(X label)
Syntax:
LabelValue<X, B> LabelValueClassObject = LabelValue.setLabel(X label)
Return Value: This method returns another LabelValueClassObject with the Label as the element passed as the parameter, and the value from the previous LabelValueClassObject. Below are programs that will illustrate the various ways to use setLabel() method: Example 1: Output:
[GeeksforGeeks, A computer science portal]
Example 2:
Output:
[One, 1]
Comment
Article Tags: