![]() ![]() ![]() We want to get a sublist starting from index 1 till index 3 from this ArrayList. In the following example, we have an ArrayList al. Example 1: Getting a sublist from an ArrayList IllegalArgumentException – if the starting index is greater than the end point index (fromIndex > toIndex). The subList method throws IndexOutOfBoundsException – if the specified indexes are out of the range of ArrayList (fromIndex size). There are few important points regarding this method which I have shared at the end of this post. Here fromIndex is inclusive and toIndex is exclusive. Syntax: List subList(int fromIndex, int toIndex) We will be using the subList() method of ArrayList class. In this tutorial, we will see how to get a sublist from an existing ArrayList. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |