In the following code what will be the output if 0 (integer value zero) is passed to m()
?
public class Main{ public void m (int x){ loop : for (int i = 1; i < 5; i++){ for (int j = 1; j < 5; j++){ System .out.println (i); if (x == 0) { continue loop; } System .out.println (j); } /*from ww w . j a va 2s.c o m*/ } } }
Select 1 option
Correct Option is : B
When x is 0, the statement continue loop; is executed.
loop: is for the outer loop.
Only one iteration is performed for the inner loop.
The inner loop prints the value of i only once and then next iteration of outer loop starts.
'j ' is never printed. So, it prints 1 2 3 4.