develog

java for break label 본문

Dev/Java

java for break label

냐옴 2014. 2. 12. 17:16

System.out.println();

System.out.println("CASE 1");

System.out.println("-------------------------------------------");

for (int i = 0; i < 3; i++) {

System.out.println(i);

for (int j = 11; j < 13; j++) {

System.out.println("\t" + j);

if (j == 11) break;

}

}

System.out.println();

System.out.println("CASE 2");

System.out.println("-------------------------------------------");

myLabel:

for (int i = 0; i < 3; i++) {

System.out.println(i);

for (int j = 11; j < 13; j++) {

System.out.println("\t" + j);

if (j == 11) break myLabel;

}

}


// output

CASE 1

-------------------------------------------

0

11

1

11

2

11


CASE 2

-------------------------------------------

0

11


'Dev > Java' 카테고리의 다른 글

[java] Ant copy  (0) 2014.02.18
variable arguments 2  (0) 2014.02.14
iBatis, remapResults="true"  (0) 2014.01.16
System.out 파일로 출력  (0) 2013.12.11
Spring 테스트 Log4j 초기화  (0) 2013.12.11
Comments