Do not call a function when declaring a for-type loop in order to avoid function calls each iterations. It saves CPU cycles.

Noncompliant Code Example

public void foo() {
    for (int i = 0; i < getMyValue(); i++) {  // Noncompliant
        System.out.println(i);
        boolean b = getMyValue() > 6;
    }
}

Compliant Solution

public void foo() {
    int myValue = getMyValue();
    for (int i = 0; i < myValue; i++) {
        System.out.println(i);
        boolean b = getMyValue() > 6;
    }
}