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;
}
//带标记的break
int i = 0;
loop:
while (true) {
while (true) {
i++;
System.out.println(i);
if (i == 100) break loop;
}
}
//带标记的continue
loop1:
while(true){
i++;
System.out.println(i);
if(i == 200) {
i = 100;
continue loop1;
}
break;
}
}
}
这里要注意的是标记一定要在循环外开始位置,也就是说标记和循环体之间不可以有其他代码。