я просто хотел знать, как получить реализацию суперкласса, используя, например, подкласс.
class Animal {
void poo() {
System.out.println("general poo");
}
}
class Horse extends Animal{
void poo() {
System.out.println("horse poo");
}
}
Animal animal1 = new Horse();
// using this I get the implementation of the Horse class's methods
animal1.poo(); //should return horse poo
попытался преобразовать его, чтобы получить реализацию суперкласса, но безрезультатно
((Animal)animal1).poo() // still returns the horse class's implementation of the method
Как получить реализацию суперкласса с помощью объекта animal1?