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 : inexpensive-ibis-a7frp9umptpo
list1 = ['a','b','c']
print(list1[-1])
Source : | Last Update : Mon, 13 Jul 20
Answered by : strange-sable-pkleq8lz6l2p
lastElement = Iterables.getLast(iterableList);
Source : https://stackoverflow.com/questions/687833/how-to-get-the-last-value-of-an-arraylist | Last Update : Fri, 05 Nov 21
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 : kritik-modi
int a[]={1,2,3};
int last = a[a.length-1];
Source : | Last Update : Sat, 27 Aug 22
Answered by : collins-emasi
# You can index using -1 to get the last item on the list
names = ['collins', 'emasi', 'sam']
l_item = names[-1]
# Output: sam
Source : | Last Update : Wed, 02 Mar 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