Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorIndexOfExample4 { 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 from index 2 System.out.println("Index of element is found at: " +in.indexOf(401, 2)); } }
Output