public int lastIndexOf(Object element)
public int lastIndexOf(Object element, int index)
These methods use equals() to check for equality.
Return -1 if not found.
The lastIndexOf() reports the position from the beginning, but starts at the end.
import java.util.Vector;
public class MainClass {
static String members[] = { "A", "I", "C", "D", "E", "F", "G", "H", "I", "J" };
public static void main(String args[]) {
Vector v = new Vector();
for (int i = 0, n = members.length; i < n; i++) {
v.add(members[i]);
}
System.out.println(v);
System.out.println(v.lastIndexOf("I"));
}
}
[A, I, C, D, E, F, G, H, I, J]
8