dimanche 27 décembre 2015

java if condition never executes with or operation

why does this piece of code always enters the if condition no matter what the input is?

 Scanner input = new Scanner(System.in);
    int x = input.nextInt();
    if (x != 4|| x!= 3)
        System.out.println("testing");

The problem is definately with the NOT combined with OR because if instead of != i write == it works (obviously different logic than what i want but still works).

Aucun commentaire:

Enregistrer un commentaire