Use of the Class object

On the subject of the use of the Class object:

“… Reassuringly, instanceof and isInstance( ) produce exactly the same results, as do equals( ) and ==. But the tests themselves draw different conclusions. In keeping with the concept of type, instanceof says “are you this class, or a class derived from this class?” On the other hand, if you compare the actual Class objects using ==, (or getClass()) there is no concern with inheritance—it’s either the exact type or it isn’t.” [ezdefinition]

Leave a Reply

Your email address will not be published. Required fields are marked *