class Cat { }
class Javier {
public static void main(
String [] args) {
Javier d = new Javier();
System.out.println(d instanceof Runnable);
//dont compile why???System.out.println(d instanceof Cat);
}
}
Hi ,
The Class Cat and Javier has no relation with one another ,
an reference can be of its own type or its Parent type ,,,,,,,,,, not like it can't be refer to the other childs of the Parent.........
parent - > child1
parent - > child2
so it can be like d is not a refernce of the Cat......... since it doesnt what is it.......has no relation between the classes of the same heriarchy......
since only Parent - child relations only makes some meaning........
try extending the
class Javier extends Cat {
}