This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Getting rid of unchecked operations related to Vector class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Getting rid of unchecked operations related to Vector class" Watch "Getting rid of unchecked operations related to Vector class" New topic
Author

Getting rid of unchecked operations related to Vector class

Tobie Henderson
Greenhorn

Joined: Nov 15, 2004
Posts: 20
Hey, I am writing a class called Pair which extends the Vector class. The constructor and add methods are the same as the Vector class. So I can create a new Pair object by:



Now, I want to add objects of another user-defined class called Player to this Pair object.



This is a problem, because it gives me "unchecked operation" errors because the raw type of Vector is not matching. How do I get rid of them? Do I have to override the constructor or the add method of the Vector class in a particular fashion to get rid of this error?
[ December 08, 2004: Message edited by: Tobie Henderson ]
Tobie Henderson
Greenhorn

Joined: Nov 15, 2004
Posts: 20
FWIW, I solved the problem. I just changed the class definition of Pair to which was previously:



to:



so that it can handle Player objects. Then I create a new Pair object by saying:



That's it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Getting rid of unchecked operations related to Vector class
 
Similar Threads
error unchecked call to addElement in vector
OO design question?
Can Vectors contain Vectors?
Simple vector prob
Getting from another class.