How to use instance of operator to check whether an object is of a particular type in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {
 
    public static void main(String[] args) {
        
        String movie = "A Space Odyssey 2001";
        
        boolean b = movie instanceof String;  
        
        System.out.println(b);
    }
}
 
/*
run:

true
 
*/

 



answered Sep 6, 2016 by avibootz
...