java中break用法

public class Test29 {

public static void main(String[] args) {

for(int i = 0; i < 10; i++) aaa:{
System.out.println(i);
if(i < 5) {
System.out.println("---" + i);
break aaa;
}
}
}

}


result

0
---0
1
---1
2
---2
3
---3
4
---4
5
6
7
8
9



猜你喜欢

转载自blog.csdn.net/zhaosx1234567/article/details/78869686