7.14 Introduction to Collections and Class ArrayList
The Java API provides several predefined data structures, called collections, used to store groups of related objects. These classes provide efficient methods that organize, store and retrieve your data without requiring knowledge of how the data is being stored. This reduces application-development time.
You’ve used arrays to store sequences of objects. Arrays do not automatically change their size at execution time to accommodate additional elements. The collection class ArrayList<T>
(from package java.util
) provides a convenient solution to this problem—it can dynamically change its size to accommodate more elements. The T
(by convention) is a placeholder—when declaring a new ArrayList ...
Get Java How to Program (early objects), 9/e 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.