JavaTuples getLabel() method
Last Updated :
27 Aug, 2018
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:
import java.util.*;
import org.javatuples.LabelValue;
class GfG {
public static void main(String[] args)
{
LabelValue<Integer, String> lv
= LabelValue.with(Integer.valueOf( 1 ), "GeeksforGeeks" );
int label = lv.getLabel();
System.out.println(label);
}
}
|
Output:
1
Example 2:
import java.util.*;
import org.javatuples.LabelValue;
class GfG {
public static void main(String[] args)
{
LabelValue<String, String> lv
= LabelValue.with( "GeeksforGeeks" ,
"A Computer Science Portal for Geeks" );
String label = lv.getLabel();
System.out.println(label);
}
}
|
Output:
GeeksforGeeks
Share your thoughts in the comments
Please Login to comment...