JavaTuples setAtX() method Last Updated : 30 Aug, 2018 Comments Improve Suggest changes Like Article Like Report The setAtX() method in org.javatuples is used to change the value in the existing tuple, at the index X. Since JavaTuples are immutable, hence changing a value in the existing tuple results in a new tuple with the modified value at the index X. It returns the tuple class object of the called class with the changed value at index X. Syntax: Quartet<String, Integer, Double, String> quartet = ... ... Quartet otherQuartet = quartet.setAtX(value); Here X represents the index at which the value is to be changed. Return Value: This method returns the tuple class object of the called class with the changed value at index X. Note: This method do not exists with KeyValue Class, and LabelValue Class. Below programs illustrate the various ways to use setAtX() methods: Program 1: When the setAtX() method is used with any class from Unit to Decade, with a direct values as parameter: Java // Below is a Java program to demonstrate // use of setAtX() method import java.util.*; import org.javatuples.Pair; class GfG { public static void main(String[] args) { // Creating a Pair with 2 values Pair<String, String> pair = Pair.with("GeeksforGeeks", "A computer science portal"); // Using Pair() method to instantiate unit object Pair otherPair = pair.setAt1("by Sandeep Jain"); // Printing the returned Pair System.out.println(otherPair); } } Output: [GeeksforGeeks, by Sandeep Jain] Program 2: Java // Below is a Java program to demonstrate // use of setAtX() method import java.util.*; import org.javatuples.Decade; class GfG { public static void main(String[] args) { // Using with() method to instantiate Decade object Decade<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> decade = Decade.with(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5), Integer.valueOf(6), Integer.valueOf(7), Integer.valueOf(8), Integer.valueOf(9), Integer.valueOf(10)); // Using setAtX() Decade otherDecade = decade.setAt9(100); // Printing the formed Decade System.out.println(otherDecade); } } Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 100] Note: Similarly, it can be used with other JavaTuple Class. Comment More infoAdvertise with us Next Article JavaTuples setAtX() method R RishabhPrabhu Follow Improve Article Tags : Java Java-Functions JavaTuples Practice Tags : Java Similar Reads JavaTuples setValue() method The setValue() method in org.javatuples is used to set the value in the LabelValueClassObject or KeyValueClassObject. This method can be used with only LabelValue class or KeyValue class of javatuples library. It returns another ClassObject with the value as the element passed as the parameter, and 2 min read JavaTuples setLabel() method The setLabel() method in org.javatuples is used to set the label of the LabelValue Class object. This method can be used with only LabelValue class object of javatuples library. It returns another LabelValueClassObject with the Label as the element passed as the parameter, and the value from the pre 2 min read JavaTuples setKey() method The setKey() method in org.javatuples is used to set the key of the KeyValue Class object. This method can be used with only KeyValue class object of javatuples library. It returns another KeyValueClassObject with the Key as the element passed as the parameter, and the value from the previous KeyVal 2 min read 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 form 2 min read JavaTuples addAtX() method The addAtX() method in org.javatuples is used to add a value to the existing tuple, at an index X. Since JavaTuples are immutable, hence adding a value to the existing tuple results in a new tuple with one more value. For example, adding a value to Unit tuple results in the formation of a Pair tuple 3 min read LinkedList set() Method in Java The Java.util.LinkedList.set() method is used to replace any particular element in the linked list created using the LinkedList class with another element. This can be done by specifying the position of the element to be replaced and the new element in the parameter of the set() method. Syntax: Link 3 min read Vector set() Method in Java The Java.util.Vector.set() method is used to replace any particular element in the vector, created using the Vector class, with another element. Syntax: Vector.set(int index, Object element) Parameters: This function accepts two mandatory parameters as shown in the above syntax and described below. 2 min read Array setFloat() method in Java The java.lang.reflect.Array.setFloat() is an inbuilt method in Java and is used to change a specified float value to a specified index of a given object array. Syntax: Array.setFloat(Object []array, int index, float value) Parameter: This method takes three parameters: array: This is an array of typ 3 min read JavaTuple getValueX() method The getValueX() method in org.javatuples is used to fetch the value of the TupleClassObject from the index X. This method can be used to any tuple class object of javatuples library. It returns the value at index X of the TupleClassObject. The returned Value is of the type of Xth element of the Tupl 2 min read Array setInt() method in Java The java.lang.reflect.Array.setInt() is an inbuilt method in Java and is used to set a specified int value to a specified index of a given object array. Syntax: Array.setInt(Object []array, int index, int value) Parameter: array: This is an array of type Object which is to be updated. index: This is 3 min read Like