OS & Program/JAVA
Java에서 while문 예제
nabiro@gmail.com
2010. 7. 29. 00:59
*** 검색어: nabiro, java, while, 예제, sample
// while문 예제입니다 import java.io.*; public class Test { public static void main(String[] ar) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int i = 0; while(true){ System.out.print("Input number:"); i = Integer.parseInt(in.readLine()); if(i > 10){ break; // while 문을 탈출 } else if (i < 5) { continue; // 아래의 라인은 실행하지 않고 다시 while 문 // 다음행으로 이동 } System.out.println("Number is " + i); } System.out.println("exit program"); } }