Extracting array from a Vector

Hello,

I have a vector that stores arrays but when I am trying to extract those arrays I get exception

"incompatible types

found: java.lang.Object

required: java.lang.String[]"

This how I define array that is going to be stored in Vector

String [] elms =new String[8];

This is an array that suppose to store extracted data from Vector

String [] outOfVector =new String[8];

This is how I populate vector

while (res.next())

{

elms[0]=res.getString("id");

elms[1]=res.getString("SERIAL_NUMBER");

elms[2]=res.getString("DESCRIPTION");

elms[3]=res.getString("PRICE");

elms[4]=res.getString("part_quantity");

elms[5]=res.getString("SUPPLIER");

elms[6]=res.getString("SUPPLY_TYPE");

elms[7]=res.getString("SUPPLY_OFFICE");

parts.add(elms);

}

and this is how I try to get the first array out of the vector

outOfVector=parts.get(1);

What am I doing wrong And how can I fix it?

Thanks

[1386 byte] By [difrad76a] at [2007-10-2 6:24:18]
# 1

Cast the Object that "get" returns:

outOfVector=(String [])parts.get(1);

And don't bother creating "new String[8]" for outOfVector. When you assign the data coming out of the Vector to outOfVector, the new array will be thrown away, anyway.

And, if it is the FIRST array, you want "get(0)".

MLRona at 2007-7-16 13:26:06 > top of Java-index,Core,Core APIs...
# 2
Even better define parts to beList<String[]> parts = new Vector<String[]>();Then you will not have to cast it when you do a call to get.
mitekea at 2007-7-16 13:26:06 > top of Java-index,Core,Core APIs...