The Java.util.Vector.lastIndexOf(Object element) method is used to check and find the occurrence of a particular element in the vector. If the element is present in the vector then the lastIndexOf() method returns the index of last occurrence of the element otherwise it returns -1. This method is used to find the last occurrence of a particular element in a vector.
Parameters: The parameter element is of type Vector. It refers to the element whose last occurrence is required to be checked.
Return Value: The method returns the position of the last occurrence of the element in the Vector. If the element is not present in the Vector then the method returns -1. The returned value is of integer type.
Below programs illustrate the Java.util.Vector.lastIndexOf() method:
Vector: [Geeks, for, Geeks, 10, 20] Last occurrence of Geeks is at index: 2 Last occurrence of 10 is at index: 3
Vector: [10, 22, 3, 10, 20] Last occurrence of 10 is at index: 3 Last occurrence of 20 is at index: 4
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- CopyOnWriteArrayList lastIndexOf() method in Java
- AbstractSequentialList lastIndexOf() method in Java with Example
- LinkedList lastIndexOf() method in Java
- Stack lastIndexOf() method in Java with Example
- StringBuilder lastIndexOf() method in Java with Examples
- AbstractList lastIndexOf() method in Java with Examples
- StringBuffer lastIndexOf() method in Java with Examples
- Java.lang.String.lastIndexOf() Method
- List lastIndexOf() Method in Java with Examples
- Stack lastIndexOf(Object, int) method in Java with Example
- Java Guava | Booleans.lastIndexOf() method with Examples
- Java Guava | Shorts.lastIndexOf() method with Examples
- Java Guava | Floats.lastIndexOf() method with Examples
- Java Guava | Doubles.lastIndexOf() method with Examples
- Java Guava | Longs.lastIndexOf() method with Examples
- Java Guava | Chars.lastIndexOf() method with Examples
- Java Guava | Bytes.lastIndexOf() method with Examples
- Vector set() Method in Java
- Vector contains() Method in Java
- Vector add() Method in Java
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.