JavaTuples toString() method Last Updated : 27 Aug, 2018 Summarize Suggest changes Share Like Article Like Report 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. Method Declaration: public final String toString() Syntax: 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: Java // Below is a Java program to use toString() method import java.util.*; import org.javatuples.Unit; class GfG { public static void main(String[] args) { // Creating an Unit with one value Unit<String> unit = Unit.with("GeeksforGeeks"); // Using toString() method String str = unit.toString(); System.out.println(str); } } Output: [GeeksforGeeks] Program 2: Using toString() with Quartet class: Java // Below is a Java program to use toString() method import java.util.*; import org.javatuples.Quartet; class GfG { public static void main(String[] args) { // Creating a quartet Quartet<Integer, String, String, Double> quartet = Quartet.with(Integer.valueOf(1), "GeeksforGeeks", "A computer portal", Double.valueOf(20.18)); // Using toString() method String str = quartet.toString(); // Printing the String System.out.println(str); } } Output: [1, GeeksforGeeks, A computer portal, 20.18] Note: Similarly, it can be used with any other JavaTuple Class. Advertise with us Next Article Java String valueOf() Method R RishabhPrabhu Follow Similar Reads MathContext toString() Method in Java The MathContext.toString() method in Java is a part of java.math package. This method is used to define the precision and rounding behaviour for BigDecimal operations. This method returns the string representation of a MathContext object's context settings. The string returned represents the setting 2 min read Object toString() Method in Java Object class is present in java.lang package. Every class in Java is directly or indirectly derived from the Object class, henceforth, it is a child of the Object class. If a class does not extend any other class then it is a direct child class of Object, and if it extends another class, then it is 3 min read Boolean toString() Method in Java In Java, the toString() method of the Boolean class is a built-in method to return the Boolean value in string format. The Boolean class is a part of java.lang package. This method is useful when we want the output in the string format in places like text fields, console output, or simple text forma 2 min read Java String valueOf() Method The valueOf() method of the String class in Java helps to convert various data types like integers, floats, booleans, and objects into their string representations. It makes it simple to work with string manipulation, logging, and displaying data efficiently.Example:To convert a number into text for 3 min read Hashtable toString() Method in Java The toString() method in the Hashtable class in Java returns a string representation of the key-value mappings contained in the hashtable. The string is in the form of a comma-separated list of key-value pairs enclosed in curly braces. The toString() method is inherited from the java.util.Hashtable 2 min read Overriding toString() Method in Java Java being object-oriented only deals with classes and objects so do if we do require any computation we use the help of object/s corresponding to the class. It is the most frequent method of Java been used to get a string representation of an object. Now you must be wondering that till now they wer 3 min read Article Tags : Java Java-Functions JavaTuples Practice Tags : Java Like