previous
|
start
|
next
Type Inquiry
Test whether
e
is a
Rectangle
:
if (e.getClass() == Rectangle.class) . . .
Ok to use
==
A unique
Class
object for every class
Test fails for subclasses
Use
instanceof
to test for subtypes:
if (e instanceof Rectangle) . . .
previous
|
start
|
next