My initial question was:
Why does the second creation fail?
This question was marked as already answered with the hint to change the question so it's something new. I will do so now
List<Animal> list = new ArrayList<Animal>();
List<Animal> list2 = new ArrayList<Cat>();
I understand that now. It is because later on you would use list2
as List of Animals. As soon as you would add a Dog, we would have a ClassCastException or similar. This is a situation that should be eliminated by using generics and thus is unacceptable else the generics implementation would be useless.
As in one of the comments is stated this should work:
List<? extends Animal> list3 = new ArrayList<Cat>();
Then why suddenly is the above explained problem gone?