Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error unchecked call to addElement in vector

 
Arun Maalik
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Dear sir when i am compiling above code then jvm showing an error message that java
warning [unchecked] unchecked call to addElement[E] as a memeber of raw type java.util
why sir what wrong with above code?

with regard

Arun kumar maalik
 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As of Java 5.0, the class Vector has been parameterized, meaning that you need to indicate what type of element your Vector object will hold.

If you compile the above code using javac -source 1.4, no unchecked warning will be thrown. This is because generics do not exist in Java 1.4.

As you want to add a String to a Vector, in Java 5.0, this should be written as:


Perhaps you should go through generics first.
[ August 16, 2006: Message edited by: Aniket Patil ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic