Just wanted to check whether the way I am thinking is correct. Here is an example method:
1 public static boolean isCircle (int M, int m) {
2 boolean result = false;
3 if (M == m & M > 0 & m > 0) {
4 result = true;
5 }
6 return result;
7 }
If I was to draw a program graph of this method (each line being a node, their path being edges) with variables that do not satisfy the conditional e.g. M = 1, m = 0. Would the program go from line 3 -> line 6, or from line 3 -> line 5 (end of the conditional). I would think line 3 to line 6 but am unsure.
It depends. Most debuggers in IDE's put the execution marker at the beginning of the line that it's about to execute. After executing the conditional in line 3 which evaluates to
false
, the next meaningful line to execute is line 6.However, consider this code:
If execution jumped to 6, that would imply that the
printf
was executed as part of the conditional, which would be frustrating for debugging.You can verify this behavior with the debugger in any IDE. You may find one or two IDE's that put the execution at the beginning of the next statement (line 6), but in the case where there is something else to execute on line 5 besides the
}
, I'd hope it'd pause the execution before jumping over that line.Any debugger worth its salt will ignore lines that don't have any meaning (whitespace, comments, open/close brackets), but pause at the beginning of each meaningful line so you can evaluate variables, set new breakpoints, etc.