Chapter 7: Arrays and Array Lists
Arrays
- Declaration, e.g. int [] census;
- Allocation, e.g. census = new int [100];
- Access, e.g. census[99]
- Assignment, e.g. census[99] = 834,000;
- Length Determination, e.g. census.length;
Array Lists
- Declaration, e.g. ArrayList<GringottsAccount> accounts;
- Allocation - automatic
- Access, e.g. accounts.get(2);
- Assignment, e.g. accounts.add(new GringottsAccount("Hermione"));
- Assignment, e.g. accounts.set(2, new GringottsAccount("Harry"));
- Removal, e.g. accounts.remove(2);
- Length Determination, e.g. accounts.size();
Wrappers and Auto-Boxing
| Primitive Type | Wrapper Class |
| boolean | Boolean |
| char | Character |
| float | Float |
| double | Double |
| byte | Byte |
| short | Short |
| int | Integer |
| long | Long |
Lecture Code