Method removeItems

Method removeItems (lines 64–68) removes a range of items from the list. Line 67 calls List method subList to obtain a portion of the List (called a sublist). This is a so-called range-view method, which enables the program to view a portion of the list. The sublist is simply a view into the List on which subList is called. Method subList takes as arguments the beginning and ending index for the sublist. The ending index is not part of the range of the sublist. In this example, line 35 passes 4 for the beginning index and 7 for the ending index to subList. The sublist returned is the set of elements with indices 4 through 6. Next, the program calls List method clear on the sublist to remove the elements of the sublist from ...

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.