Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: converting vector to array
|
Posted: Mar 6, 2002 1:17 PM
|
|
If you mean converting a Vector to an Integer object array, then you can simply use the toArray() method. If you want an array of int, then I think you have to do it yourself, but it would be pretty straight forward:
static int [] vectorToIntArray( Vector v )
{
int [] array = new int[v.size()];
Iterator it = v.iterator();
for( int i = 0; it.hasNext(); i++ )
{
try
{
array[i] = ((Integer)it.next()).intValue();
}
catch( ClassCastException cce )
{
array[i] = 0;
}
}
return array;
}
|
|