class BBB { }
class CCC extends BBB { }
The instanceof operator is useful when it is necessary to find the
runtime type of an object. The declared type might be a supertype.
class DDD extends BBB { }
public class X {
public static void main(
String[] args) {
BBB c = new CCC();
BBB d = new DDD();
X.checkIt(c); // prints true
X.checkIt(d); // prints false
}
private static void checkIt(BBB b) {
System.out.println(b instanceof CCC);
}
}