J.5.3. Views into Collections and Arrays Method asList
An important feature of the collections framework is the ability to manipulate the elements of one collection type (such as a set) through a different collection type (such as a list), regardless of the collection’s internal implementation. The set of public
methods through which collections are manipulated is called a view.
Class Arrays
provides static
method asList to view an array (sometimes called the backing array) as a List collection. A List
view allows you to manipulate the array as if it were a list. This is useful for adding the elements in an array to a collection and for sorting array elements. The next example demonstrates how to create a LinkedList
with a List
view of an array, ...
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.