Java Reference
In-Depth Information
Summary of Key Concepts
An array of size N is indexed from 0 to N− 1.
In Java, an array is an object that must be instantiated.
Bounds checking ensures that an index used to refer to an array element is
in range.
An initializer list can be used to instantiate an array object instead of using
the new operator.
An entire array can be passed as a parameter, making the formal param-
eter an alias of the original.
Instantiating an array of objects reserves room to store references only.
The objects that are stored in each element must be instantiated separately.
Command-line arguments are stored in an array of String objects and are
passed to the main method.
A Java method can be defined to accept a varying number of parameters.
Using an array with more than two dimensions is rare in an object-ori-
ented system.
A polyline is similar to a polygon except that a polyline is not a closed
shape.
Moving the mouse and clicking the mouse button generate events to which
a program can respond.
A listener may have to provide empty method definitions for unheeded
events to satisfy the interface.
Rubberbanding is the graphical effect caused when a shape seems to
expand as the mouse is dragged.
Key events allow a program to respond immediately to the user pressing
keyboard keys.
Exercises
Visit www.myprogramminglab.com to complete many of these Exercises
online and get instant feedback.
EX 8.1
Which of the following are valid declarations? Which instantiate
an array object? Explain your answers.
int primes = {2, 3, 4, 5, 7, 11};
float elapsedTimes[] = {11.47, 12.04, 11.72, 13.88};
Search WWH ::




Custom Search