Introduction to List and Constructing ArrayList Objects
Have you ever made a list? kept a budget? used a spreadsheet? These are collections of related items we call a list. One way that we can represent this in a program is by using a List, specifically an ArrayList.
An ArrayList is a resizable list, meaning it shrinks and grows as needed.
How Data is Stored?
Each value stored in an ArrayList is called an element. As elements are added to the ArrayList the size of the ArrayList increases by 1.
Similar to the characters in a String, each element in an ArrayList has an index. The first index is 0 and the last is the size of the ArrayList - 1.
Constructing an ArrayList
When constructing an ArrayList object, we must specify the type of data that is stored. An ArrayList only stores reference data. Wrapper classes will be used to store any primitive data.
General Format for Constructing an ArrayList
An example of an ArrayList of student names in a class would be as follows:
An example of an ArrayList of a student's grades would be as follows:
Complete List of ArrayList Tutorials
- Learn: Constructing an ArrayList Object
- Learn: Adding Values to an ArrayList Object
- Learn: Accessing and Removing Values from an ArrayList Object
- Learn: Changing Values in an ArrayList Object
- Learn: Analyzing an ArrayList Object
- Learn: Iterating Over an ArrayList Object