Junior — Senior
Refactoring code considering differences between List<? extends>, List<? super>, and specific types
livecode
Task condition
It is necessary to modify the existing code, considering the following questions:
- How do lists list1, list2, and list3 differ?
- What elements can be added to each of these lists?
- What types of objects can be safely retrieved from them?
- In which situations should you use the extends constraint, and in which — super?
class A {}
class B extends A {}
class C extends B {}
List<? extends B> list1 = ...
List<? super B> list2 = ...
List<B> list3 = ...