What is the output of the following code? “`java int i = 0; while (i++ < 3) { if (i == 2) continue; System.out.print(i + " "); } “`

Java Professional Hard

Java Professional — Hard

What is the output of the following code? “`java int i = 0; while (i++ < 3) { if (i == 2) continue; System.out.print(i + " "); } “`

Key points

  • The continue statement skips the current iteration and moves to the next one.
  • The loop runs until i is less than 3.
  • The output includes all values of i except 2.
  • The final value of i is 4.

Ready to go further?

Related questions