 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
All
arrays of class types must be defined using new (with an
|
|
|
exception
of the String class….)
|
|
|
– |
list
[] array = new list[size];
|
|
| • |
But,
such arrays are actually arrays of references to our objects – not
|
|
instances!
|
|
|
– |
(like
an array of pointers in C++)
|
|
| • |
If
you forget to allocate objects for the elements, you will get an
|
|
|
exception
|
|
| • |
List
[] array = new list[] {new list(1), new list (2), new list(3)};
|
|
| • |
Or,
do this explicitly with a loop
|
|
| • |
Unlike
C and C++, Java allows the return type of functions to be an
|
|
|
array
|
|