This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
the JVM has no idea that your ArrayList was supposed to hold only
Integers. The typing information does not exist at runtime! All your generic code
is strictly for the compiler. then how come the casting is not reqiured while retrieving the contents...... Ex List<String> list = new ArrayList<String>();
String name = list.get(0);
1. Create a simple program that uses generics.
2. Compile the program to a class file.
3. Get hold of a decompiler and decopile the class file created in step 2.
4. Look at the source code of the decompiled file.
Try these steps and see if it answers your question
To help you further try compiling and then decompiling this code,