JavaTuples toString() method
The toString() method in org.javatuples is used to convert the values in TupleClass into a String. This method is inherited from the JavaTuple class. This method can be used to any tuple class object of javatuples library. It returns a String value formed with the values in the TupleClassObject.
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 final String toString()
String str = TupleClassObject.toString()
Here TupleClassObject represents the JavaTuple Class object used like Unit, Quintet, Decade, etc.
Return Value: This method returns a String value which contains the elements of the TupleClassObject, separated by ‘, ‘.
Below programs illustrate the various ways to use toString() method:
Program 1: Using toString() with Unit class:
Program 2: Using toString() with Quartet class:
[1, GeeksforGeeks, A computer portal, 20.18]
Note: Similarly, it can be used with any other JavaTuple Class.