mercredi 29 juillet 2015

Check integer number is between two values

I have a int variable named number with value 21.

int number = 21;

if (number >= 6 && number < 12) {
    System.out.println("catch 1");
}
else if (number >= 12 && number < 17) {
    System.out.println("catch 2");
}
else if (number >= 17 && number < 21) {
    System.out.println("catch 3");
}
else if (number >= 21 && number < 6) {
    System.out.println("catch 4");
}

Why i can't see the catch 4 message?

Aucun commentaire:

Enregistrer un commentaire