Hi, can anyone please share me an example of for each loop. I'm having a problem with it. Thank you


1 2 3 4 | private void agitateBalls() { for (Ball ball : (List<Ball>)getIntersectingObjects(Ball. class )) ball.agitateColor(); } |
1 2 3 4 | private void agitateBalls() { for (Object obj : getIntersectingObjects(Ball. class )) ((Ball)obj).agitateColor(); } |
1 2 3 4 5 6 7 8 | private void agitateBalls() { for (Object obj : getIntersectingObjects(Ball. class )) { Ball ball = (Ball)obj; ball.agitateColor(); } } |
1 2 3 4 5 6 7 8 | private void agitateIntersectors() { for (Object obj : getIntersectingObjects(Actor. class )) { if (obj instanceof Ball) ((Ball)obj).agitateColor(); if (obj instanceof Box) ((Box)obj).agitateSize(); } } |