JavaTuples getLabel() method
The getLabel() method in org.javatuples is used to fetch the label from the TupleClassObject from the LabelValue Class. This method can be used with only LabelValue class object of javatuples library. It returns a Label which is the element present at the index 0 of the LabelValueClassObject. The returned Label is ensures the type-safety.
Method Declaration:
public A getLabel()
Syntax:
LabelValue LabelValueClassObject = LabelValue.with(A a, B b); A val = LabelValueClassObject.getLabel()
Return Value: This method returns a Label which is the element present at the index 0 of the LabelValueClassObject.
Below programs illustrate the various ways to use getLabel() method:
Example 1:
// Below is a Java program to get // a LabelValue value import java.util.*; import org.javatuples.LabelValue; class GfG { public static void main(String[] args) { // Creating a LabelValue object LabelValue<Integer, String> lv = LabelValue.with(Integer.valueOf(1), "GeeksforGeeks"); // Using getLabel() method int label = lv.getLabel(); // Printing the Label System.out.println(label); } } |
Output:
1
Example 2:
// Below is a Java program to get // a LabelValue value import java.util.*; import org.javatuples.LabelValue; class GfG { public static void main(String[] args) { // Creating a LabelValue object LabelValue<String, String> lv = LabelValue.with("GeeksforGeeks", "A Computer Science Portal for Geeks"); // Using getLabel() method String label = lv.getLabel(); // Printing the Label System.out.println(label); } } |
Output:
GeeksforGeeks
Recommended Posts:
- JavaTuples with() method
- JavaTuples add() method
- JavaTuples contains() method
- JavaTuples fromIterable() method
- JavaTuples getValue() method
- JavaTuples containsAll() method
- JavaTuples getSize() method
- JavaTuples fromArray() method
- JavaTuples toString() method
- JavaTuples setValue() method
- JavaTuples setAtX() method
- JavaTuples hashcode() method
- JavaTuples getKey() method
- JavaTuples indexOf() method
- JavaTuples setKey() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



