Home Java JDK 8 Features Spring Boot React JS Servlet Data JPA JDBC Microservices Hibernate

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

 

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