How is Java\'s for loop code generated by the compiler?
For example, if I have:
for(String s : getStringArray() ) { //do something with s }
Compiler might call it just once, but you can depend on it. It may not be a good coding practice. If getStringArray() returns same array each time, why not set to a variable first?
getStringArray()
EDIT - answer changed with the comments received.