instanceof Operator in java

instanceof in java
The java instanceof operator is used to test if an object belongs to a class or not.Note that the word instance meaans object.This operator can also be used to check if an object belongs to an interface or not.

boolean variable = object instanceof class;
boolean variable = object instanceof interface;
This could be written as:
boolean x = emp instanceof employee;

Leave a Reply

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