The instanceof Keyword
by , 04-26-2012 at 05:33 PM (545 Views)
Instanceof operator can be used for determining that dog is an animal & Mammal is an animal.
interface Animal{}
Following result will be produced:Java Code:class Mammal implements Animal{} class Dog extends Mammal{ public static void main(String args[]){ Mammal m = new Mammal(); Dog d = new Dog(); System.out.println(m instanceof Animal); System.out.println(d instanceof Mammal); System.out.println(d instanceof Animal); } }
true
true
true









Email Blog Entry
License4J 4.0
Yesterday, 12:23 AM in Java Software