Using the following code:
public class Animal {
public void a() {
System.out.println("Animal");
}
}
public class Cat extends Animal {
public void a() {
System.out.println("Cat");
}
}
public class BlackCat extends Cat {
public static void main(String[] args) {
BlackCat blackCat = new BlackCat();
blackCat.a();
}
}
How to use in child class BlackCat method a() from Animal but not from Cat?
I want to receive Animal in console.
I guess you could add an addition function with a set prefix (this case _) and use that as your "super accessor" or what ever you want to call it.
public class Cat extends Animal {
public void a() {
System.out.println("Cat");
}
public void _a() {
super.a();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With