The lastIndexOf() method of ArrayList in Java is used to get the index of the last occurrence of an element in an ArrayList object.
Parameter : The element whose last index is to be returned.
It returns the last occurrence of the element passed in the parameter. It returns -1 if the element is not found.
Program to demonstrate the working of lastIndexOf():
The list initially [10, 20, 30, 40, 30, 30, 40] the lastIndexof of 30 is 5 100 is not present in the list
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Java.util.LinkedList.indexOf(), lastIndexof() in Java
- ArrayList of ArrayList in Java
- Stack lastIndexOf() method in Java with Example
- Vector lastIndexOf() Method in Java
- LinkedList lastIndexOf() method in Java
- CopyOnWriteArrayList lastIndexOf() method in Java
- AbstractSequentialList lastIndexOf() method in Java with Example
- Java.lang.String.lastIndexOf() Method
- Stack lastIndexOf(Object, int) method in Java with Example
- Ints lastIndexOf() function | Guava | Java
- StringBuilder lastIndexOf() method in Java with Examples
- StringBuffer lastIndexOf() method in Java with Examples
- List lastIndexOf() Method in Java with Examples
- AbstractList lastIndexOf() method in Java with Examples
- Java Guava | Bytes.lastIndexOf() method with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.