ArrayList Class
Package: java.util
The ArrayList
package lets you create and maintain a special type of collection object: an array list. An array list is similar to an array but averts many of the most common problems of working with arrays, specifically the following:
An array list automatically resizes itself whenever necessary.
An array list lets you insert elements into the middle of the collection.
An array list lets you delete items.
Constructors
Constructor |
Explanation |
|
Creates an array list with an initial capacity of ten elements. |
|
Creates an array list with the specified initial capacity. |
|
Creates an array list and copies all the elements from the specified collection into the new array list. |
Methods
Method |
Explanation |
|
Adds the specified object to the array list. If you specified a type when you created the array list, the object must be of the correct type. |
|
Adds the specified object to the array list at the specified index position. If you specified a type when you created the array list, the object must be of ... |
Get Java For Dummies Quick Reference now with the O’Reilly learning platform.
O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.