previous | start | next

Syntax 13.4: The instanceof Operator

  object instanceof TypeName

Example:

 
if (anObject instanceof BankAccount)
{
   BankAccount anAccount = (BankAccount) anObject;
   . . .
}

Purpose:

To return true if the object is an instance of TypeName (or one of its subtypes), and false otherwise

previous | start | next