fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. public class Main{
  9. public static void main(String[] args) {
  10. int n=0;
  11. while (n < 10) {
  12. System.out.println(n); // starts with 0 and will reach until 9
  13. n++;
  14. if (n >= 5) { // n starts with 1 and breaks starting with 5
  15. break;
  16. }
  17. System.out.println("What should happen here? n=" + n); // because it will reach here from 1 to 4
  18. }
  19. }
  20. }
Success #stdin #stdout 0.08s 48168KB
stdin
Standard input is empty
stdout
0
What should happen here? n=1
1
What should happen here? n=2
2
What should happen here? n=3
3
What should happen here? n=4
4