aspose file tools*
The moose likes Beginning Java and the fly likes warning [unchecked] unchecked call to add() in ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "warning [unchecked] unchecked call to add() in ArrayList" Watch "warning [unchecked] unchecked call to add() in ArrayList" New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: warning [unchecked] unchecked call to add() in ArrayList
 
Similar Threads
compiling under 1.5
Warnings after compiling program using Generics
collections doubt
I am close to submit - eliminate a warning message
Linked Lists (Java Collections framework)