An enhanced for statement obtains an Iterable's iterator, checks hasNext(), assigns next() to the loop variable, runs the body, and repeats. Its predictable call order can conceal broken custom Iterator implementations. section 8.13
A contract violation hidden by for-each
An iterator that advances inside hasNext() may work for `for (int value : range(10))`, yet fail when a utility calls next() before hasNext(), or calls hasNext() repeatedly. Implement next() with its own bounds check and advance only after returning the current value. section 8.13
Avoid relying on enhanced-for call patterns:
- Support next() before hasNext(), repeated hasNext() calls, and NoSuchElementException when exhausted. section 8.13
