📄 labeledwhile.java
字号:
//: c03:LabeledWhile.java
// Java's "labeled while" loop.
import com.bruceeckel.simpletest.*;
public class LabeledWhile {
public static void main(String[] args) {
SimpleTest monitor =
new SimpleTest("LabeledWhile");
int i = 0;
outer:
while(true) {
prt("Outer while loop");
while(true) {
i++;
prt("i = " + i);
if(i == 1) {
prt("continue");
continue;
}
if(i == 3) {
prt("continue outer");
continue outer;
}
if(i == 5) {
prt("break");
break;
}
if(i == 7) {
prt("break outer");
break outer;
}
}
}
monitor.expect(new String[] {
"Outer while loop",
"i = 1",
"continue",
"i = 2",
"i = 3",
"continue outer",
"Outer while loop",
"i = 4",
"i = 5",
"break",
"Outer while loop",
"i = 6",
"i = 7",
"break outer"
});
}
static void prt(String s) {
System.out.println(s);
}
} ///:~
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -