Answers for "how to find last index of array in java"

1

ArrayList lastIndexOf(Object o) method in java

import java.util.ArrayList;
public class ArrayListLastIndexOfMethodExample
{
   public static void main(String[] args)
   {
      ArrayList<Integer> al = new ArrayList<Integer>();
      al.add(40);
      al.add(98);
      al.add(20);
      al.add(98);
      al.add(35);
      al.add(45);
      al.add(35);
      System.out.println("Last occurrence of element 98 is: " + al.lastIndexOf(98));
      System.out.println("Last occurrence of element 35 is: " + al.lastIndexOf(35));
   }
}
Posted by: Guest on October-29-2020

Code answers related to "how to find last index of array in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language