The instanceof operator

The instanceof operator is used to check whether an object belongs to a certain class.
In other words, it is only used on reference types, not on primitive types (but it can be used on primitive types wrapper classes).
The left operand of the expression is the reference to the object to check, and the right operand is the class name.

Since java.lang.String is derived from java.lang.Object and the instanceof operator always return false on a null instance, the output looks like this:

Search for more Java info on this site here:
Custom Search

Any thoughts or questions?