Try to Convert Vector to int

if(Foods.isEmpty()!=true)

{

int x = 0;

int z =0;

for(int j =0; j<Foods.size(); j++)

{

x++;

int[]i = (int [])(Energys.elementAt(j));

i[j] = z;

totalE[j] = z; // totalE[] is a int array.

System.out.println(z);

For the following code i got no compilation error but when run reaching the line. Errors java.lang.ClassCastException

at DW.commandAction(+1832)

at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+282)atjavax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10)

at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68)

atcom.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47)at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+250)

What can i do? Can anyone help thanks>

[841 byte] By [YellowSheepa] at [2007-10-3 9:53:23]
# 1
The elements in your Vector are not of the type int[]. Use the correct one!
deepspacea at 2007-7-15 5:11:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
Check whether the element of vector is integer array. Else it wil give ClassCastException
Mmamathaa at 2007-7-15 5:11:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
Check whether the element of vector is integer array. Else it wil give ClassCastException
Mmamathaa at 2007-7-15 5:11:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
Hi,Make sure the object you getting from the vector is an Integer type. Then in a simple way you can parse like this,int value = Integer.parseInt(vect.elementAt(i).toString());
pissing_crowa at 2007-7-15 5:11:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5
Hey thanks alot for your tipS!
YellowSheepa at 2007-7-15 5:11:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...