Java Instanceof Operator

This operator only used for object reference variables. This operator is used to check if the present object is a type of that class/interface or not.

class Demo{  
 public static void main(String args[]){  
 Demo s=new Demo();  
 System.out.println(s instanceof Demo);//true  
 }  
}
Example Output

Share