Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorIndexOfExample2 { public static void main(String arg[]) { //Create a first empty vector Vector
vec = new Vector<>(4); //Add elements in the first vector vec.add("Java"); vec.add("JavaScript"); vec.add("Android"); vec.add("Python"); //Obtain an index of first occurrence of the specified element System.out.println("Index of element is: " +vec.indexOf("C")); System.out.println("The element is not found."); } }
Output