Answers for "last index of a arraylist 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
0

how to get last index of array in java

//grabing a last element of the array
firstNum = numbers[0];
lastNum = numbers[numbers.length-1];
Posted by: Guest on August-06-2021

Code answers related to "last index of a arraylist java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language