mercredi 4 novembre 2015

IntelliJ - Warning message does not appear for the condition i >= 2 when i is known

The following program on IntelliJ

public static void main(String[] args) {
    int i = 0;
    if (i <= 2) {
        System.out.println("ok");
    }
}

warns me "Condition 'i <= 2' is always 'true'". If I replace the condition with i > 2 , I get "Condition 'i > 2' is always 'false'". Same with i == 2.

But if I replace it with i >= 2 I don't have any warnings.

Why in the last case IntelliJ does not warn me that this condition is always false ?

I'm using IntelliJ 14.1.5 and the compiler used is javac in its 1.8.0_51 version.

enter image description here

Aucun commentaire:

Enregistrer un commentaire