| Author |
Warnings with Collections API
|
Reema Patel
Ranch Hand
Joined: Jan 26, 2006
Posts: 169
|
|
Hello All, Pls. consider the following code: I get a warning when i compile tgis code snippet. I compiled it with -Xlint:unchecked, and I get to see the following warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List What does this mean? How can i remove the warning? Any help shall be highly appreciated. Thanks, Reema
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24054
|
|
Java 5 introduced "generics", which provides a way to make collections that are "typesafe". You can read about it here. Short answer: this code List<String> titles=new ArrayList<String>(); titles.add("A"); will not give the warning. Read the document linked to above to start to learn why.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Reema Patel
Ranch Hand
Joined: Jan 26, 2006
Posts: 169
|
|
|
Thanks for the post!
|
 |
 |
|
|
subject: Warnings with Collections API
|
|
|