Section 7.16 Introduction to Collections and Class ArrayList

• The Java API’s collection classes provide efficient methods that organize, store and retrieve data without requiring knowledge of how the data is being stored.

• An ArrayList<T> (p. 288) is similar to an array but can be dynamically resized.

• The add method (p. 290) with one argument appends an element to the end of an ArrayList.

• The add method with two arguments inserts a new element at a specified position in an ArrayList.

• The size method (p. 290) returns the number of elements currently in an ArrayList.

• The remove method with a reference to an object as an argument removes the first element that matches the argument’s value.

• The remove method with an integer argument ...

Get Java™ How To Program (Early Objects), Tenth 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.