JavaTuples fromArray() method Last Updated : 30 Aug, 2018 Comments Improve Suggest changes Like Article Like Report The fromArray() method in org.javatuples is used to instantiate a tuple in a semantically elegant way, with the values of the array, given as parameters. This method can be used to any tuple class object of javatuples library. It is a static function in each javatuple class and it returns the tuple class object of the called class, with the values initialized by the corresponding values of the array. Method Declaration: public static <X> TupleClass<X> fromArray(X[] array) Syntax: TupleClass<X> obj = TupleClass.fromArray(X[] array) Parameters: This method takes array as parameter where: X- represents the datatype of values in the array. array- represents the array of values to be inserted into TupleClass. TupleClass- represents the JavaTuple Class used like Unit, Quintet, Decade, etc. Return Value: This method returns the object of TupleClass, which calls the method, with the values of the array, passed as the parameters. Below programs illustrate the various ways to use fromArray() method: Program 1: Using fromArray() with Unit class: Java // Below is a Java program to create // a Unit tuple from fromArray() method import java.util.*; import org.javatuples.Unit; class GfG { public static void main(String[] args) { // Creating an array with one value String str[] = { "GeeksforGeeks" }; // Using fromArray() method Unit<String> unit = Unit.fromArray(str); System.out.println(unit); } } Output: [GeeksforGeeks] Program 2: Using fromArray() with Decade class: Java // Below is a Java program to create // a Unit tuple from fromArray() method import java.util.*; import org.javatuples.Decade; class GfG { public static void main(String[] args) { // Creating an array with 10 value String str[] = { "Geeks", "for", "Geeks", "A", "Computer", "Science", "Portal", "for", "Geeks", "RishabhPrabhu" }; // Using fromArray() method Decade<String, String, String, String, String, String, String, String, String, String> decade = Decade.fromArray(str); System.out.println(decade); } } Output: [Geeks, for, Geeks, A, Computer, Science, Portal, for, Geeks, RishabhPrabhu] Note: Similarly, it can be used with any other JavaTuple Class. Comment More infoAdvertise with us Next Article JavaTuples fromArray() method R RishabhPrabhu Follow Improve Article Tags : Java Java-Functions JavaTuples Practice Tags : Java Similar Reads JavaTuples fromIterable() method The fromIterable() method in org.javatuples is used to instance a tuple in a semantically elegant way, with the values of the iterable, given as parameters. This method can be used for any tuple class object of the javatuples library. It is a static function in each javatuple class and it returns th 2 min read JavaTuples fromCollection() method The fromCollection() method in org.javatuples is used to instantiate a tuple in a semantically elegant way, with the values of the collection, given as parameters. This method can be used to any tuple class object of javatuples library. It is a static function in each javatuple class and it returns 2 min read Array get() Method in Java The java.lang.reflect.Array.get() is an inbuilt method in Java and is used to return the element at a given index from the specified Array. Syntax Array.get(Object []array, int index) Parameters : This method accepts two mandatory parameters: array: The object array whose index is to be returned. in 3 min read Array set() method in Java The java.lang.reflect.Array.set() is an inbuilt method in Java and is used to set a specified value to a specified index of a given object array. Syntax Array.set(Object []array, int index, Object value) Parameter : array : This is an array of type Object which is to be updated. index : This is the 3 min read 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 JavaTuple toArray() method 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 th 2 min read Array getInt() Method in Java The java.lang.reflect.Array.getInt() is an inbuilt method in Java and is used to return an element at the given index from the specified Array as a int. Syntax Array.getInt(Object []array, int index) Parameters: This method accepts two mandatory parameters: array: The object array whose index is to 3 min read Array getByte() Method in Java The java.lang.reflect.Array.getByte() is an inbuilt method in Java and is used to return the element present at the given index from the specified Array as a Byte.Syntax: Array.getByte(Object []array, int index) Parameters : This method accepts two mandatory parameters: array: The object array whose 3 min read Arrays.stream() Method in Java Arrays.stream() method is used to get a sequential Stream from the elements of an array passed as a parameter. Below is a simple example that uses Arrays.stream() to convert a String array into a Stream for sequential processing.Example:Java// Java program to demonstrate Arrays.stream() method impor 3 min read Array getLong() Method in Java The java.lang.reflect.Array.getLong() is an inbuilt method in Java and is used to return an element at the given index from a specified Array as a long. Syntax: Array.getLong(Object []array, int index) Parameters : This method accepts two mandatory parameters: array: The object array whose index is 3 min read Like