I would like to implement an Iterator in Java that behaves somewhat like the following generator function in Python:
Iterator
def iterator(array): for
The translation from Python-style generators to Java-style iterators can be automated. If you're willing to accept code generation in your build process, you might be interested in this prototype tool that does the translation for you:
https://github.com/Calvin-L/gen2it