Answered by : stupid-seal-lkprxu0vos8u
firstNum = numbers[0];
lastNum = numbers[numbers.length-1];
Source : https://stackoverflow.com/questions/39860739/how-to-get-first-and-last-element-in-an-array-in-java | Last Update : Fri, 15 May 20
Answered by : busy-badger-oydyepme7a8i
ArrayList<Integer> list = new ArrayList<Integer>(5);
int last = list.get(list.size() - 1);
Source : | Last Update : Sat, 06 Jun 20
Answered by : proton
int e = list.get(list.size() - 1);
Source : https://stackoverflow.com/questions/687833/how-to-get-the-last-value-of-an-arraylist | Last Update : Fri, 05 Aug 22
Answered by : dark-dogfish-f96qufu7cjdu
List<Post> myLastPosts = posts.subList(posts.size()-40, posts.size());
Source : https://stackoverflow.com/questions/37219424/get-last-x-items-of-a-list-in-java | Last Update : Thu, 27 Aug 20
Answered by : dark-dogfish-f96qufu7cjdu
List<E> tail = l.subList(Math.max(l.size() - 3, 0), l.size());
Source : https://stackoverflow.com/questions/14605999/getting-the-last-three-elements-from-a-list-arraylist | Last Update : Thu, 27 Aug 20
Answered by : outstanding-okapi-ka4n9df41foa
// Array of doubles
double[] array_doubles = {2.5, 6.2, 8.2, 4846.354, 9.6};
// First position
double firstNum = array_doubles[0]; // 2.5
// Last position
double lastNum = array_doubles[array_doubles.length - 1]; // 9.6
Source : https://stackoverflow.com/questions/39860739/how-to-get-first-and-last-element-in-an-array-in-java | Last Update : Fri, 14 Jan 22