Hi,
It won't allow Mamal and animal addition. It only means you can pass the super type of Dog but
you can only add Dog and its sub-types, not the super-type. Hope this helps.
The reason is just to support
polymorphism. Factually its a Animal list, it could have something like
a Cat objected added. So if it would allow the addition and all, what when you will be taking things
out of your Dog list and Cat object comes. You will be dead according to K&B.
Plus do remember type erasure, at run-time, not type information is available by JVM to support the
legacy code.
Arhaan