Skip to content
Advertisement

Is it possible to override an inherited method with type parameter List with List?

I’m having trouble changing the type parameter of an inherited method.

JavaScript

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.

Advertisement

Answer

I don’t know what the best solution is, but I would do the following:

JavaScript

JavaScript

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement