A
Alessandro
Hi all,
I have a static ArrayList "buffer" with many objects. All of them
belongs to 3 classes (RicDataCrossElement, RicDataTassiElement,
RicDataUpdElement) which are childs of RicDataElement class.
I need to extract every object from this list and do some actions
according to the different class.
I have errors in the following code, please could you help ?
Of course I'm also doing more and more "next()" and every time I'm
passing to the following item ... so that's wrong !
//START CODE
....
public static ArrayList<RicDataElement> buffer;
....
Iterator<? extends RicDataElement> iter1 = buffer.iterator();
while (iter1.hasNext())
{
if(iter1.next() instanceof RicDataCrossElement){
RicDataCrossElement crossElm=
(RicDataCrossElement )iter1.next();
...
}
else if(iter1.next() instanceof RicDataTassiElement){
RicDataTassiElement tassiElm=(RicDataTassiElement)
iter1.next();
...
}
else if(iter1.next() instanceof RicDataUpdElement){
RicDataUpdElement updElm=(RicDataUpdElement)iter1.next
();
...
}
}
}
//END CODE
Thanks for any help and best regards,
Alessandro
I have a static ArrayList "buffer" with many objects. All of them
belongs to 3 classes (RicDataCrossElement, RicDataTassiElement,
RicDataUpdElement) which are childs of RicDataElement class.
I need to extract every object from this list and do some actions
according to the different class.
I have errors in the following code, please could you help ?
Of course I'm also doing more and more "next()" and every time I'm
passing to the following item ... so that's wrong !
//START CODE
....
public static ArrayList<RicDataElement> buffer;
....
Iterator<? extends RicDataElement> iter1 = buffer.iterator();
while (iter1.hasNext())
{
if(iter1.next() instanceof RicDataCrossElement){
RicDataCrossElement crossElm=
(RicDataCrossElement )iter1.next();
...
}
else if(iter1.next() instanceof RicDataTassiElement){
RicDataTassiElement tassiElm=(RicDataTassiElement)
iter1.next();
...
}
else if(iter1.next() instanceof RicDataUpdElement){
RicDataUpdElement updElm=(RicDataUpdElement)iter1.next
();
...
}
}
}
//END CODE
Thanks for any help and best regards,
Alessandro