I'm having trouble changing the type parameter of an inherited method.
abstract class Animal {
abstract List<Animal> animalList();
}
public class Dog extends Animal {
@Override
public List<Dog> animalList() {
...
...
}
}
public class Cat extends Animal {
@Override
public List<Cat> animalList() {
...
...
}
}
All animal subclasses need to implement a method animalList. What's the best practice of doing this if i want the best possible code regarding readability and maintainability? Please note that this is extremely simplified i comparison to the actual project.