Let testIt()
public static int testIt() { System.out.println("testIt()"); return 2; } public static void main(String[] args) { for (int i = 0; i < testIt(); i++) { System.out.println(i); } }
Output
testIt() 0 testIt() 1 testIt()
Answer: it is compared at each iteration of the loop, which makes it more likely for lower numbers.
It may differ in other languages. Even if it is not today, it may be tomorrow. If you want to know, you should check it out.
Edit
For example, in Java 8 you can write
import static java.util.stream.IntStream.rangeClosed;
source share