warning [unchecked] unchecked call to add() in ArrayList
Joined: Sep 14, 2005
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.
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
Joined: Dec 06, 2001
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".