| Author |
warning [unchecked] unchecked call to add() in ArrayList
|
Graham Cole
Greenhorn
Joined: Sep 14, 2005
Posts: 4
|
|
|
I get a warning such as the one in the subject line of this post whenever I call things like .add() or .put() (depending on the type of variable of course). I'm wondering what a "checked" call would look like so that I can ensure the stability of my program and get the compiler to quit warning me about me ramped disregard for checking calls.
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
The warning is about the "type safety" introduced by generics in Java 1.5. To eliminate the warnings, you can specify the type of object that the ArrayList is supposed to hold -- for example, ArrayList<String>... [ October 06, 2005: Message edited by: marc weber ]
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
|
|
As you can see, the method call itself does not change. You need to change the declaration of your ArrayList variable instead. If you want more information about this, google for "Java generics". Layne
|
Java API Documentation
The Java Tutorial
|
 |
 |
|
|
subject: warning [unchecked] unchecked call to add() in ArrayList
|
|
|