首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

带标记的break跟continue

2012-08-22 
带标记的break和continueenum Size {BIG, SMALL}public class Test {public static strictfp void main(S

带标记的break和continue

enum Size {BIG, SMALL};public class Test {public static strictfp void main(String[] args) throws InterruptedException {//以枚举作为case判断条件Size size = Size.SMALL;switch(size){case SMALL:System.out.println("小号");break;case BIG:System.out.println("大号");break;}//带标记的breakint i = 0;loop:while (true) {while (true) {i++;System.out.println(i);if (i == 100) break loop;}}//带标记的continueloop1:while(true){i++;System.out.println(i);if(i == 200) {i = 100;continue loop1;}break;}}}

这里要注意的是标记一定要在循环外开始位置,也就是说标记和循环体之间不可以有其他代码。

热点排行