I’m experiencing a strange problem. I have a case statement, and it is not being entered, at all. I’ve stepped it through with the Eclipse debugger and it gets the line above and then goes straight to the line after. It compiles and runs with no errors.
This is a general outline:
for (int k = 0; k<9; k++) {
System.out.println("Program is here - #1");
doSomething();
switch (switchcode) {
case 1:
switch (k) {
case 1: case 2: case 3:
doOneOneTwoThree(); //#2
break;
case 4: case 5: case 6:
doOneFourFiveSix(); //#3
break;
default:
System.err.println("error k defaulted in case 1");
break;
}
break;
case 2:
switch (k) {
case 1: case 2: case 3:
doTwoOneTwoThree(); //#4
break;
case 4: case 5: case 6:
doTwoFourFiveSix(); //#5
break;
default:
System.err.println("error k defaulted in case 2");
break;
}
break;
default:
System.err.println("error switchcode defaulted");
break;
}
doSomethingElse();
}
I’m doing something wrong, no doubt, but I really don’t know what exactly.
Is it because I am switching on k within a case? I have done this before and it has worked, perhaps luckily.
Is the nesting of case statements within a larger for-loop causing problems?
I saw “Branch Prediction Fail” occasionally whilst I was researching around, I don’t know exactly what that is but it might be happening.
Is having break; in the default cases causing problems? I don’t think it is because I tried it without them and had the same results.
Sorry for the long code and question. Thanks for ANY guidance.
If Eclipse doesn’t hit a line it should, then the source might be out-of-sync with the code compiled by Eclipse.
Try to do a clean & new build.
Restarting Eclipse or reimporting the project might also help.