JavaTuples setAtX() method
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
JavaTuples setAtX() method
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.
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:
[GeeksforGeeks, by Sandeep Jain]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 100]
Note: Similarly, it can be used with other JavaTuple Class.
Please Login to comment...