SE450
:
Type Inquiry
[19/86]
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) . . .