1import java.util.ArrayList;
2public class ArrayListLastIndexOfMethodExample
3{
4 public static void main(String[] args)
5 {
6 ArrayList<Integer> al = new ArrayList<Integer>();
7 al.add(40);
8 al.add(98);
9 al.add(20);
10 al.add(98);
11 al.add(35);
12 al.add(45);
13 al.add(35);
14 System.out.println("Last occurrence of element 98 is: " + al.lastIndexOf(98));
15 System.out.println("Last occurrence of element 35 is: " + al.lastIndexOf(35));
16 }
17}