0

# For each know last iteration

In Java for each how i know the last iteration without adding a new variables? For (int n : numbers){ // How i know the last iteration? }

2 Answers

+ 2

int len = numbers.length - 1;
for(int n : numbers){
if(n == numbers[len]){
// do something
}
}

0

yes is correct, but my question was without adding new variable. It's seems there is nothing method.
I have midified original question
thanks ;)