File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes genrics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "genrics" Watch "genrics" New topic


santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
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);

Creativity is nothing but Breaking Rules
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 607

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,

Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
I agree. Here's the link:
subject: genrics
It's not a secret anymore!