I can only seem to find answers about last/first element in a list or that you can get a specific item etc.
Lets say I have a list of 100 elements, and I want to return the last 40 elements. How do I do that? I tried doing this but it gave me one element..
Post last40posts = posts.get(posts.size() -40);
Do use the method sub list
List<Post> myLastPosts = posts.subList(posts.size()-40, posts.size());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With