get the last element of an array list in java code example
Example 1: arraylist get last
E e = list.get(list.size() - 1);
Example 2: get last n elements from list java
List<Post> myLastPosts = posts.subList(posts.size()-40, posts.size());
E e = list.get(list.size() - 1);
List<Post> myLastPosts = posts.subList(posts.size()-40, posts.size());