The indexOf() method in org.javatuples is used to find the index of a value, passed as parameter, in TupleClass. This method takes the parameter of Object type, so that it can check for all type of values. It is inherited from the JavaTuple class. This method can be used to any tuple class object of javatuples library. It returns an int which is the first index of the value passed as the parameter, if found. If not found, then it returns -1.
public final int indexOf(Object value)
int index = TupleClassObject.indexOf(Object value)
Here TupleClassObject represents the JavaTuple Class object used like Unit, Quintet, Decade, etc.
Return Value: This method returns an int which is the first index of the value passed as the parameter, if found. If not found, then it returns -1.
Below programs illustrate the various ways to use indexOf() method:
Program 1: Using indexOf() with Unit class:
Index of GeeksforGeeks = 0 Index of Present = -1
Program 2: Using indexOf() with Quartet class:
Index of GeeksforGeeks = 1 Index of 5 = -1
Note: Similarly, it can be used with any other JavaTuple Class.
- Vector indexOf() Method in Java
- LinkedList indexOf() method in Java
- CopyOnWriteArrayList indexOf() method in Java
- AbstractSequentialList indexOf() method in Java with Example
- Stack indexOf() method in Java with Example
- JavaTuples contains() method
- JavaTuples add() method
- JavaTuples with() method
- AbstractList indexOf() method in Java with Examples
- Stack indexOf(Object, int) method in Java with Example
- StringBuffer indexOf() method in Java with Examples
- List indexOf() Method in Java with Examples
- StringBuilder indexOf() method in Java with Examples
- JavaTuples addAtX() method
- JavaTuples equal() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.