The Source for Java Technology Collaboration
User: Password:



Start New Message Delete Post a Reply

Weblog:   Eye of the Tiger - Generics in J2SE 1.5
Subject:  Confused about erasure
Date:  2003-12-03 07:04:56
From:  sam_dalton


You can get the above example to work by declaring your collection thus:

ArrayList<String> l = new ArrayList<String>();

This will not allow you to add anything to you collection that is NOT a String (doing so will result in a compile time error).

 Feed java.net RSS Feeds