I have the following scenario:
public class A {
}
public class B extends A {
}
public class C extends B {
public void Foo();
}
I have a method that can return class A, B or C and I want to cast safely to C but only if the class type is C. This is because I need to call Foo() but I don't want the ClassCastException.