loop:while (true) {
Scanner sc = new Scanner(System.in);
System.out.println(“请输入您的选择:”);
String result = sc.next();
switch (result){
case “5”-> {
System.out.println(“退出”);
break loop;
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
停止虚拟机运行
```java
while (true) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入您的选择:");
String result = sc.next();
switch (result){
case "5"-> {
System.out.println("退出");
System.exit(0);
}
}
跳出多重循环
- 本文链接: https://readmengk90.github.io/2024/02/11/java基础-跳出多重循环/
- 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!