0%

跳出多重循环

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);
}
}