how to find the last index position in a list java code example
Example 1: java get last element of list
ArrayList<Integer> list = new ArrayList<Integer>(5);
int last = list.get(list.size() - 1);
Example 2: 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);