java: how many times is the collection expression evaluated in a "foreach"

Viewed 2967

if I do this in Java:

for(String s : myCollection.expensiveListGeneration())
{
      doSomething();
}

is expensiveListGeneration() invoked just once at the beggining or in every cycle iteration?

Is it implementation dependent?

2 Answers
Related