December 2015
Beginner
698 pages
15h 16m
English
ArrayList is like a regular Java array on steroids. It overcomes some of the shortfalls of arrays such as having to predetermine its size. It adds some really useful methods to make its data easy to manage, and it uses an enhanced version of a for loop, which is clearer to use than a regular for loop.
Let's look at some code that uses ArrayList:
// Declare a new ArrayList called myList to hold int variables ArrayList<int> myList; // Initialize the myList ready for use myList = new ArrayList<int>();
In the previous code, we declared and initialized a new ArrayList called myList. We can also do this in a single step as shown in the following code:
ArrayList<int> myList = new ArrayList<int>();
We have seen nothing especially interesting so ...
Read now
Unlock full access