GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — JavaTutorial/src/F029_BreakAndContinue.java at master · windweb/JavaTutorial Expand file tree/ Copy pathF029_BreakAndContinue.javaMore file actions 50 lines (36 loc) · 1.4 KB / Copy pathF029_BreakAndContinue.javaFile metadata and controls50 lines (36 loc) · 1.4 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 /* Break and Continue / Прерывание и переход к следующей итерации цикла break и continue можно использовать в циклах. break - прерывание цикла continue - переход к следующей итерации цикла pass - ничего не делает Пример: while (условие) { // do something if (условие) { // do something continue; // переход к следующей итерации цикла } if (условие) { break; // прерывание цикла } if (условие) { pass; // ничего не делает } } */ import java.util.Scanner; public class F029_BreakAndContinue { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String input = ""; while (true) { System.out.print("Enter something or 'stop' or 'password': "); input = scanner.next().toLowerCase(); if (input.equals("password")) continue; // переход к следующей итерации цикла, но не выхода из цикла if (input.equals("stop")) break; // выход из цикла while (прерывание цикла) System.out.println("You entered: " + input); } } } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |