ArrayList.lastIndexOf(Object o) has the following syntax.
public int lastIndexOf(Object o)
In the following code shows how to use ArrayList.lastIndexOf(Object o) method.
/* ww w. ja va 2 s . co m*/ import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList<String> arrlist = new ArrayList<String> (5); arrlist.add("G"); arrlist.add("E"); arrlist.add("F"); arrlist.add("M"); arrlist.add("E"); arrlist.add("from java2s.com"); System.out.println("Size of list: " + arrlist.size()); System.out.println(arrlist); // Retrieving the index of last occurrence of element "E" int retval=arrlist.lastIndexOf("E"); System.out.println("The last occurrence of E is at index " + retval); } }
The code above generates the following result.