Answers for "last index of 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
3

get last index of array java

int[] someArray = {1,2,3,4,5};
int first = someArray[0];
int last = someArray[someArray.length - 1];
System.out.println("First: " + first + "\n" + "Last: " + last);
Posted by: Guest on August-16-2020
1

arraylist get last

E e = list.get(list.size() - 1);
Posted by: Guest on July-03-2020
0

get last n elements from list java

List<Post> myLastPosts = posts.subList(posts.size()-40, posts.size());
Posted by: Guest on August-20-2020
0

get last n elements from list java

List<E> tail = l.subList(Math.max(l.size() - 3, 0), l.size());
Posted by: Guest on August-20-2020

Code answers related to "last index of arraylist java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language