J.5. Lists

A List is an ordered Collection that can contain duplicate elements. Like array indices, List indices are zero based (i.e., the first element’s index is zero). In addition to the methods inherited from Collection, interface List provides methods for manipulating elements via their indices, manipulating a specified range of elements, searching for elements and obtaining a ListIterator to access the elements.

Interface List is implemented by several classes, including ArrayList (introduced in Appendix E) and LinkedList. Class ArrayList is a resizable-array implementation of List. Inserting an element between existing elements of an ArrayList is an inefficient operation—all elements after the new one must be moved out of the way, which ...

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.