Mega Code Archive

 
Categories / Java Book / 005 Collection
 

0300 Get element index

int indexOf(Object o) Returns the index of the first occurrence of the specified element in this vector, or -1 if this vector does not contain the element. int indexOf(Object o, int index) Returns the index of the first occurrence of the specified element in this vector, searching forwards from index, or returns -1 if the element is not found. int lastIndexOf(Object o) Returns the index of the last occurrence of the specified element in this vector, or -1 if this vector does not contain the element. int lastIndexOf(Object o, int index) Returns the index of the last occurrence of the specified element in this vector, searching backwards from index, or returns -1 if the element is not found.