
Putting the size of the
array inside the brackets in
the array declaration will
generate a compiler error.
COMMON ERROR
TRAP
466 CHAPTER 8 Single-Dimensional Arrays
Similarly, this statement declares an array to hold the answers to a
true/false test:
boolean [ ] answers; // each element is a boolean value
Using our Auto class from Chapter 7, this statement declares an array to
hold Auto objects:
Auto [ ] cars; // each element is an Auto object reference
You can declare multiple arrays of the same data type in one statement by
inserting a comma after each array name, using this syntax:
datatype [ ] arrayName1, arrayName2;
For example, the following statement ...