Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Double to Vector

Status
Not open for further replies.

bunnyweb

MIS
Jan 13, 2003
42
IE
Is it not possible to add a double value to a Vector? This is what I'm trying (basically):

Vector vecTest = new Vector();
double mynumber = 1.1;
vecTest.add(mynumber);

I'm getting the following error:

method(add)double not found in class java.util.Vector

I am importing java.util.Vector and I can add strings to vecTest. What's the deal?

I'm still pretty new to Java, so please be kind. :)

Thanks!

Rachel
 
Vector v = new Vector();
double d = 1.03456;
v.add(new Double(d));

a "double" is no Object, and a Vector can take only Objects.
Wrapping the "double" in a "Double" (which is an Object) will allow you to put it into a Vector.
Same thing applies to boolean (Boolean), int (Integer) etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top