If method_returning_array() returns large array read the footnote too.
Enhanced for loop is just a syntactic sugar, it can take any subtype of Iterable or Array.
In your case, since method is returning array it will be compiled as:
Let L1 ... Lm be the (possibly empty) sequence of labels immediately preceding the enhanced for statement. Then the meaning of the enhanced for statement is given by the following basic for statement:
T[] a = Expression;
L1: L2: ... Lm:
for (int i = 0; i < a.length; i++) {
VariableModifiersopt Type Identifier = a[i];
Statement
}
Where a and i are compiler-generated identifiers that are distinct from any other identifiers (compiler-generated or otherwise) that are in scope at the point where the enhanced for statement occurs.
And method_returning_array() is only called once.
IMPORTANT:
But there is a related bug,2 which got fixed in Java 10, which may impact you if method_returning_array() returns really large array. Workaround is to use traditional for loop:
for (int i = 0; i < a.length; i++)
For details, read