Any simple way to explain why I cannot do List<Animal> animals = new ArrayList<Dog>()? [duplicate]
This question already has an answer here: Is List<Dog> a subclass of List<Animal>? Why are Java generics not implicitly polymorphic? 16 answers I know why one shouldn't do that. But is there way to explain to a layman why this is not possible. You can explain this to a layman easily : Animal animal = new Dog(); . A dog is a kind of animal but a list of dogs is not a list of animals. Imagine you create a list of Dogs . You then declare this as List<Animal> and hand it to a colleague. He, not unreasonably , believes he can put a Cat in it. He then gives it back to you, and you now have a list of