Hi hab ein Problem mit einer For-Each-Schleife. Ich habe zwei ArrayLists die ich abwechselnd (X-Wert und Y-Wert) auslesen will. Dies muss unbedingt abwechselnd passieren da die Werte immer zusammen gehören und da ich beide Werte zusammen überprüfen will.
Danke schon mal im Vorraus.
Gruß
Code:
public void controlXY(){
for(Object posXEqual : listX){
Integer intWrapperX = (Integer)posXEqual;
int intX = intWrapperX.intValue();
if(intX+20>foodX&&intX-20<foodX){
foodX = generateFoodX();
controlXY();
}
}
for(Object posYEqual : listY){
Integer intWrapperY = (Integer)posYEqual;
int intY = intWrapperY.intValue();
if(intY+20>foodY&&intY-20<foodY){
foodY = generateFoodY();
controlXY();
}
}
}
Danke schon mal im Vorraus.
Gruß