JavaTuple toArray() method Last Updated : 27 Aug, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The toArray() method in org.javatuples is used to convert the values in TupleClass into an array of Object type. This method is inherited from the JavaTuple class. This method can be used to any tuple class object of javatuples library. It returns an array of Object type formed with the values in the TupleClassObject. Method Declaration: public final Object[] toArray() Syntax: Object obj[] = TupleClassObject.toArray() Here TupleClassObject represents the JavaTuple Class object used like Unit, Quintet, Decade, etc. Return Value: This method returns an array of Object type formed with the values in the TupleClassObject. Below are programs that will illustrate the various ways to use toArray() method: Program 1: Using toArray() with Unit class: Java // Below is a Java program to use toArray() 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 toArray() method Object[] object = unit.toArray(); // Printing the array elements for (Object obj : object) { System.out.println(obj); } } } Output: GeeksforGeeks Program 2: Using toArray() with Quartet class: Java // Below is a Java program to use toArray() 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 toArray() method Object[] object = unit.toArray(); // Printing the array elements for (Object obj : object) { System.out.println(obj); } } } Output: 1 GeeksforGeeks A computer portal 20.18 Note: Similarly, it can be used with any other JavaTuple Class. Comment More infoAdvertise with us Next Article Java Collection toArray() Method R RishabhPrabhu Follow Improve Article Tags : Java Java-Functions JavaTuples Practice Tags : Java Similar Reads JavaTuple toList() method The toList() method in org.javatuples is used to convert the values in TupleClass into a List. This List is of Object type, so that it can take all values. It is inherited from the JavaTuple class. This method can be used to any tuple class object of javatuples library. It returns List formed with t 2 min read 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. Met 2 min read Set toArray() Method in Java In Java, the toArray() method is used to convert a collection to an array. It returns an array containing all the elements in the collection in the correct order.Example 1: Converting a Set to an ArrayThis is an example where a Set of String elements is converted into an array using the toArray() me 2 min read LinkedList toArray() Method in Java In Java, the toArray() method is used to convert a LinkedList into an Array. It returns the same LinkedList elements but in the form of an Array only.Example: Here, we use toArray() to convert a LinkedList into an Array of Integer.Java// Java Program to Demonstrate how to use toArray() method // to 4 min read Java Collection toArray() Method The toArray() method of Java Collection returns an array containing elements that are inside the calling collection. This article will discuss the toArray() method, its syntaxes, how it works, and some code examples. Syntax of toArray() MethodObject[] toArray();Return Type: The return type of the ab 3 min read ArrayDeque toArray() Method in Java The java.util.ArrayDeque.toArray() method is used to form an array of the same elements as that of the Deque. Basically, the method copies all the element from this deque to a new array. Syntax: Object[] arr = Array_Deque.toArray() Parameters: The method does not take any parameters. Return Value: T 2 min read Like