The question title is vague, because I don't know how to describe my it.
Given the following code:
String getLargeText() {
    // loads a large text from somewhere
    // and returns it
}
Vecor<String> tokenize(String text) {
    // seperate the text into tokens and
    // return them as a vector of strings
}
public static void main(String[] args) {
    String text = getLargeText();  
    for(String token : tokenize(text)) {
        // some action with 'token'
    }
}
Will the 'tokenize' function in the foreach-loop be called at every iteration, or just once and have its return value be re-used? It looks like the kind of thing which a good compiler would optimize, but I am not sure if java does it. And if the answer to the first question is yes, will
for(volatile String token = tokenize(text)) { ...
supress that behaviour?
