previous
|
start
|
next
Retrieving Array List Elements
Use
get
method
Index starts at 0
BankAccount anAccount = accounts.get(2); // gets the third element of the array list
Bounds error if index is out of range
Most common bounds error:
int i = accounts.size();
anAccount = accounts.get(i); // Error
// legal index values are 0. . .i-1
previous
|
start
|
next