EDIT: thanks for the reply antiplastik, i wrote this without checking if anyone had replied first... I'll see if i can work out ArrayList, I've seen it mentioned elsewhere.
Ok, after a bit of looking round (that I admittedly should have spent longer on before posting originally) i found the concat function.
This avoids the problem of the ClassCast problem, however it seems to do something strange and I can't pin down what's happening. Basically, what I think should happen is that if a particular stem has reached 600, it should remove that from the array, but leave the others. However, on running it, when one reaches that point, they all get deleted.
I presume this has something to do with program flow, but i can't work it out.
Code:
void update(){
println(stems.length);
for (int f=0;f<stems.length;f++){
if (stems[f].rY>600){
//we should delete if from the array
stem[] arrayP1 = (stem[]) subset(stems,1,f);
stem[] arrayP2 = (stem[]) subset(stems,f+1);
println(arrayP1.length);
println(arrayP2.length);
stems = (stem[])concat(arrayP1,arrayP2);
println(stems.length);
break;
}
stems[f].update();
}
}
Any help would be appreciated.
Thanks
Martin