Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

check instance of java

// instanceof Checks whether object is instance of a given class
Object obj = new String("Hello World!");
// obj is instance of String and as such first msg is printed out		
if(obj instanceof String) {
	System.out.println(obj + " is instance of String class"); // This msg is printed
} else {
	System.out.println(obj + " is not instance of String class");
}
 
PREVIOUS NEXT
Tagged: #check #instance #java
ADD COMMENT
Topic
Name
2+3 =