previous | start | next

Syntax 9.3: The instanceof Operator

  object instanceof ClassName

Example:

  if (x instanceof Coin)
{
   Coin c = (Coin)x;
}

Purpose:

To return true if the object is an instance of ClassName (or one of its subclasses), false otherwise


previous | start | next