samedi 10 octobre 2020

When does this post-incrementation happen?

I have this piece of Java code in front of me:

private static int[] generateSparseArray(int value) {
    int[] array = new int[getBound(value)];
    for (int j = 1; j < value; j++) {
        do {
            array[j++] = value;
            if ((value++ > 3 || value < 4) && (j > 0)) {
                ++j;
                break; 
            }
        } while (value < 4); 
    }
    return array; 
}

private static int getBound(int value) { /** ... */ }

I am not sure if this will increment "value" after checking specifically this piece of the boolean expression or if it will increment after the entire boolean expression of the if-statement.

What do you guys think?

Aucun commentaire:

Enregistrer un commentaire