This is something that I can’t omit, now I have something like this:
boolean method1(int a){
returns true;
}
boolean method2(int a){
returns true;
}
for (int i; i<100; i++){
switch (someInt){
case 1: boolean x = method1(i);
case 2: boolean x = method2(i);
}
}
What I would like is to take the switch out of the loop, since someInt will remain unchanged for each i, so it needs to be solved only once, but I need x to be checked for each i, so I would need something like:
switch (someInt){
case 1: method1();
case 2: method2();
}
for (int i; i<100; i++){
boolean x = method the switch above picked
}
source
share