• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java 1.5 unchecked calls

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am migrating some of my code to Java 1.5, and I have some warnings of unchecked calls on the use of java.util.Vector, as follows

<pre>
warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
ruleList.add(newRule);
</pre>

Honestly, I have absolutely no idea what this means, is it true that a vector is supposed to be array that you can add your objects to and retrieve them later, whatever the objects are.

As the code still compiles and works, I dont really have a problem with these warnings. However, it'll be great if someone tell me what it means, and what is "right" way to work with these calls.

TIA,

Tim.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With JDK 5 "generics" you can declare collections to contain only certain types. To make this go away you could code:

That's pretty cool as now the compiler will only let you add Rule objects to the vector and you won't have to cast them when you pull them back out.

But it might be a huge change to your application. So you could also look up the compiler flag to check for 1.4 syntax instead of 1.5 syntax.

See if that helps!
reply
    Bookmark Topic Watch Topic
  • New Topic