IDEA-142912 (Intention: replace switch with if failed with bit operator (operator precedence))

This commit is contained in:
Bas Leijdekkers
2015-08-27 17:45:58 +02:00
parent ff0dce8379
commit d57591cd2c
3 changed files with 32 additions and 2 deletions
@@ -0,0 +1,13 @@
// "Replace 'switch' with 'if'" "true"
class Precedence {
void m() {
int a = 10;
if ((a & 1) == 0) {
System.out.println("0");
} else if ((a & 1) == 1) {
System.out.println("1");
}
}
}
@@ -0,0 +1,14 @@
// "Replace 'switch' with 'if'" "true"
class Precedence {
void m() {
int a = 10;
switch<caret>(a & 1) {
case 0:
System.out.println("0");
break;
case 1:
System.out.println("1");
}
}
}