Arrays+and+ArrayLists

Arrays and ArrayLists

Topics: 1. One-dimensional arrays - initialization, length (size), traversing an array, arrays as parameters

An //array// is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed. Arrays of any type can be declared:

code byte[] anArrayOfBytes; short[] anArrayOfShorts; long[] anArrayOfLongs; float[] anArrayOfFloats; double[] anArrayOfDoubles; boolean[] anArrayOfBooleans; char[] anArrayOfChars; String[] anArrayOfStrings; code

To assign a value to an array, you call the array, the location inside of the bracket, and then the value. For example: anArray[0] = 100; int[] anArray = {100, 200, 400};

2. Two dimensional arrays - declarations, processing, traversing, as a parameter

2-dimensional arrays are arrays that represent rows and columns. They are declared similar to regular arrays, except an additional bracket is needed. For example: int[][] a2 = **new** int[10][5]; This code declares an array with 10 rows and 5 columns. Two dimensional arrays are often processed by using nested loops } } 3. The ArrayList  class - Collections API, the Collections hierarchy, auto-boxing and -unboxing 4. The List  interface - the methods of List , the ArrayList class, using it 5. Collections and iterations - definition of an iterator, the Iterator Interface, using a generic Iterator