Java Reference
In-Depth Information
Resumes execution of all threads waiting on the in-
voking object.
void notifyAll( )
String toString( )
Returns a string that describes the object.
void wait( )
void wait(long
milliseconds
)
void wait(long
milliseconds
, int
nanoseconds
)
Waits on another thread of execution.
The methods
getClass( )
,
notify( )
,
notifyAll( )
, and
wait( )
are declared as
final
. You
can override the others. Several of these methods are described later in this topic. However,
notice two methods now:
equals( )
and
toString( )
. The
equals( )
method compares two
objects. It returns
true
if the objects are equivalent, and
false
otherwise. The
toString( )
method returns a string that contains a description of the object on which it is called. Also,
this method is automatically called when an object is output using
println( )
. Many classes
override this method. Doing so allows them to tailor a description specifically for the types
of objects that they create.
One last point: Notice the unusual syntax in the return type for
getClass( )
. This relates
to Java's
generics
feature. Generics allow the type of data used by a class or method to be
specified as a parameter. Generics are discussed in
Chapter 13
.
Chapter 7 Self Test
cess to the members of a superclass?
putes the area of the circle and a constructor that uses
super
to initialize the
TwoDShape
portion.