자바 썸네일형 리스트형 label을 이용한 break문 예제) public class Test10 {public static void main(String[] args) {int n=0; gogo:while(true){System.out.println("밖깥 while 위");while(true){n++;if(n>=10) break gogo; if(n>=5) break; System.out.println(n);}System.out.println("바깥 while 아래");}System.out.println("프로그램 끝"); }} 결과) 바깥 while 위1234바깥 while 아래바깥 while 위바깥 while 아래바깥 while 위바깥 while 아래바깥 while 위바깥 while 아래바깥 while 위바깥 while 아래바깥 while 위프로그램 끝 더보기 switch ~ case문 예제1) switch ~ case문 public class Test1 {public static void main(String[]args) { int a=3; switch(a) {case 3:System.out.print("*");case 2:System.out.print("#");case 1:System.out.print("$");}}} 예제1 결과) a변수의 값을 2혹은 1로 바꾸면 다른 값이 출력되는 것을 확인할 수 있다. *#$ ============================================================= 예제2) switch ~ case문과 break문 public class aa {public static void main(String[]args) { int a.. 더보기 do~ while과 for문을 이용한 프로그램 예제) import java.io.IOException;import java.io.InputStreamReader;import java.io.BufferedReader; public class Test5{public static void main(String[] args) throws IOException {BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); char ch;int num;int s;while(true) {do{System.out.print("수 ?");num=Integer.parseInt(br.readLine()); //리드라인은 엔터입력을 버린다.}while (num1000); // 1에서 1000까지의 수를 .. 더보기 for문 안의 for문(별 표 찍기) 예제1) public class Test1{public static void main(String[] args) { int a,b;for(a=1; a 더보기 for 문 예제1) public class Test1{public static void main(String[] args) { int n,s;s=0;for(n=1;n 더보기 do~while 문법 예제1) public class Test1 {public static void main(String[] args) {int n,s; n=0; s=0;do{n++;s+=n;}while(n 더보기 while 문법 예제1) public class Test1 {public static void main(String[] args) {int n,s; n=0; s=0;while(n 더보기 if ~ else 문(평년, 윤년) 예제) import java.io.IOException;import java.io.InputStreamReader;import java.io.BufferedReader; public class Test14 {public static void main(String[] args) throws IOException {BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int a,b,c; System.out.print("년도 ?");a=Integer. parseInt(br.readLine()); if(a%4==0&&a%100!=0||a%400==0) {System.out.println(a+": 윤년");} elseSystem.out.p.. 더보기 이전 1 ··· 6 7 8 9 10 11 12 13 다음