I'm a bit confused about how Java generics handle inheritance / polymorphism.
Assume the following hierarchy -
Animal (Parent)
Dog - Cat (Children)
So suppose I have a method doSomething(List<Animal> animals). By all the rules ...
Why is it that java.util.List does not implement Serializable while subclasses like LinkedList, Arraylist do? Does not it seem to be against inheritance principles? For example if we want ...
The other Example is pretty complex and I didn't understand it at all, my problem is similar somehow but as I said it's simpler and might yield in simpler answer
Class B extends class A. I have a list of B (List<B> list1), but for some operations I need only class A fields, but List<A> list2 = list1 doesn't work. How ...