public int indexOf(Object element) public int indexOf(Object element, int index)
The indexOf() method uses the equals() method to find out if two elements are the same. If the element is not found, indexOf() will return -1.
import java.util.Vector; public class MainClass { public static void main(String args[]) { Vector v = new Vector(); v.add("A"); v.add("B"); int index = v.indexOf("B"); System.out.println(index); } }
1