JavaTuples removeFromX() method
The removeFromX() method in org.javatuples is used to remove a value from the existing tuple, from the index X. Since JavaTuples are immutable, hence removing a value from the existing tuple results in a new tuple with one value less. For example, removing a value from Pair tuple results in the formation of a Unit tuple. This method can be used for any tuple class object of the javatuples library, except the Unit class,, as Unit is the smallest class available in JavaTuples library with only 1 value. It returns the tuple class object of a class smaller than the called class.
Quartet<String, Integer, Double, String> quartet = ... ... Triplet<String, Integer, Double> triplet = quartet.removeFromX();
Here X represents the index from which the value is to be removed.
Return Value: This method returns the tuple class object of a class smaller than the called class. The removed value is from the index X mentioned in the method name.
Note: This method do not exists with Unit Class, KeyValue Class, and LabelValue Class.
Below programs illustrate the various ways to use removeFromX() methods:
Program 1: When the removeFromX() method is used with any class from Pair to Decade, with a direct values as parameter:
[2, 3, 4, 5, 6, 7, 8, 9, 10]
Note: Similarly, it can be used with other JavaTuple Class.