
If you think of the brackets
as being part of the data
type of the array,then it’s
easy to remember that the
brackets are included in the
method header—where
the data types of parame-
ters are given—but that
brackets are not included
in method calls,where the
data itself is given.
COMMON ERROR
TRAP
496 CHAPTER 8 Single-Dimensional Arrays
for ( int i = 0; i < arr.length; i++ )
{
System.out.println ( arr [i] );
animate( i );
}
■
Verify that you did not instantiate a new array. Perform all opera-
tions on the array passed to the method as a parameter.
8.5 Using Arrays in Classes
8.5.1 Using Arrays in User-Defined Classes
An array can be used inside a user-defined class ...