This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
In chapter 7 page 602/603 in K&B, it explains that for legacy code to work, the compiler will allow you to put anything into a collection but will generate a warning. Why is the following example producing an error instead of a warning.
This would generate a compiler warning about raw types, but you'd be allowed to put anything into the list as you describe.
An important thing to understand about generics in Java is they are only applied at compile time. The types running in the JVM would still look like the legacy code above. Since you specify the type of the list, the compiler enforces what you can put into it, e.g. a String "is not" an AnimalA. The compiler will automatically change the code above to which would allow you to put the String in there since String "is a" Object.
Everything is theoretically impossible, until it is done. ~Robert A. Heinlein