View Full Version : Copy all vector values to a int[] - how?

Rune Carlsen
02-26-2005, 07:07 PM
This is java....

I have a vector, myvector.
I want all values in this vector to be put inside a int[].
I have tried this, but it doesn't work:
int[] tmp = myvector.toArray( new int[myvector.size()]);

Gives me this error:
The method toArray() in the type Vector is not applicable for the arguments (int[])

ANyone have a idea?


02-27-2005, 08:03 AM
A vector holds Objects so you won't be able to get ints from it, only Integers (assuming that's what you put into it). The syntax would be something like:

Integer[] tmp = (Integer[])myvector.toArray();