In Java, I have parent class P and a child class C.
In an abstract class, I have a method void blah(P parent). In a child class of the abstract class, it doesn’t compile by having void blah(C child).
How do I achieve the type check in the child class?
void blah(P parent)andvoid blah(C child)are actually different methods. That’s why you can not use the C Child to override an abstract P parent method.So, in your child class of the abstract class, you can either
Or just implement these two methods separately.