Is there an elegant way to skip the first iteration in a Java5 foreach loop ?
Example pseudo-code:
for ( Car car : cars ) {
//skip if first, do w
This might not be elegant, but one could initialize an integer variable outside the for loop and increment it with every iteration within the loop. Your program would only execute if the counter is bigger than 0.
int counter = 0;
for ( Car car : cars ) {
//skip if first, do work for rest
if(counter>0){
//do something
}
counter++;
}