Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorIndexOfExample3 { public static void main(String arg[]) { //Create a first empty vector Vector
vec = new Vector<>(4); //Add elements in the first vector vec.add("Facebook"); vec.add("Whatsapp"); vec.add("Twitter"); vec.add("Instagram"); vec.add("Skype"); //This would start searching of element from index -2 System.out.println("Index of element is found at: " +vec.indexOf("Skype", -2)); } }
Output