• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

warning [unchecked] unchecked call to add() in ArrayList

 
Graham Cole
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic