You can't use the instanceof operator to test across two different class hierarchies. class Cat { } class Dog { public static void main(String [] args) { Dog d = new Dog(); System.out.println(d instanceof Cat); } }
Incompatible conditional operand types Dog and Cat