10-break-continue-exit.java 600 B

123456789101112131415161718192021222324252627282930313233343536
  1. class Main {
  2. public static void main(String[] args) {
  3. System.out.println("=> Uso de break");
  4. for (int i = 0; i < 10; i++) {
  5. if (i == 5) {
  6. break;
  7. }
  8. System.out.println(i);
  9. }
  10. System.out.println("=> Uso de continue");
  11. for (int i = 0; i < 10; i++) {
  12. if (i == 5) {
  13. continue;
  14. }
  15. System.out.println(i);
  16. }
  17. System.out.println("=> Uso de exit");
  18. for (int i = 0; i < 10; i++) {
  19. if (i == 5) {
  20. System.exit(0);
  21. }
  22. System.out.println(i);
  23. }
  24. System.out.println("=> Fin del programa");
  25. }
  26. }