//我稍微修改了一下你的代码,你试试看行不行
import java.util.Scanner;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("请输入:");
Integer num = in.nextInt();
String day = "";
switch (num) {
case 1:
day = "MON";
break;
case 2:
day = "TUE";
break;
case 3:
day = "WED";
break;
case 4:
day = "THU";
break;
case 5:
day = "FRI";
break;
case 6:
day = "SAT";
break;
case 7:
day = "SUN";
break;
default:
System.out.println("输入有误!");
break;
}
System.out.print(day);
}
空值“”不能转化为Integer类型。加个判断。为空返回,或者为空让他等于0.
Scanner in=new Scanner(System.in);
int num=in.nextInt();
双重for循环更简单点