Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorLastIndexOfExample4 { public static void main(String arg[]) { //Create an empty Vector Vector < Integer > in = new Vector < > (); //Add elements in the vector in.add(101); in.add(201); in.add(301); in.add(401); in.add(501); //This would start searching of element in the backward direction from index 3 System.out.println("Index of element is found at: " +in.lastIndexOf(201, 3)); } }
Output