In Java, suppose I have 3 classes, C extends from B which extends from A.
And I have one method:
public void f(A a);
If I do something like this:
C c = new C()
B b = (B) c;
f(b);
f accepts b as type C since C and B both extend from A. I wanted f to receive b as type B and not type C.
Is there anyway to force this upcasting?