InstanceOf Operator


The Java instanceof Operator is used to determining whether this object belongs to this particular (class or subclass or interface) or not.

Example:

class Employee {

}

public class InstanceOfOperator {

            public static void main(String[] args) {

                        Employee e1 = new Employee();

                        System.out.println(e1 instanceof Employee);

            }

}

Output:

true