instanceof Operator


  • instanceof is for reference variables only, and checks for whether the object is of a particular type.
  • The instanceof operator can be used only to test objects (or null) against class types that are in the same class hierarchy.
  • For interfaces, an object passes the instanceof test if any of its superclasses implement the interface on the right side of the instanceof operator.