• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

genrics

 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>();
list.add("santhosh");
String name = list.get(0);
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic