Arrays That Are Not Full &�Parallel Arrays
Putting Values into the Array Using the Intializer List
int [ ] array1 = {1,2,3,4,5};
Declaring Multiple Arrays
int [ ] array1 = new int [100], array2 = new int [100];
Be sure to include the “new” term when declaring arrays. Failure to do this will result in a �null pointer exception.
Declaring Multiple Arrays
int [ ] array1 = new int [100];
array2 = array1;
Since array1 and array2 refer to the same set of array elements, changing one will result in a �change to the other.
Copying From One Array �to Another
int [ ] array1 = new int [100], array2 = new int [100];
int i;
for (i = 0; i < 100; i++) {
array1[i] = array2[i];
}
Working With Arrays That Are Not Full
Working With Arrays That Are Not Full
Working With Arrays That Are Not Full
Parallel Arrays
Ex:
String [ ] name = {“Bill”, “Sue”, “Jan”, “Joe”};
int [ ] age = {20 , 21 , 19 , 14 };