import java.util.Scanner;
public class Demo8 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner=new Scanner(System.in);
System.out.println("请输入月份");
int mon = scanner.nextInt();
String sea;
switch(mon){
case 1:
case 2:
case 12:
sea ="winter";
break;
case 3:
case 4:
case 5:
sea="spring";
break;
case 6:
case 7:
case 8:
sea="summer";
break;
case 9:
case 10:
case 11:
sea="autumn";
default:
System.out.println("月份错误");
}
System.out.println(sea);
}
}
结果如下:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The local variable sea may not have been initialized
at Demo8.main(Demo8.java:37)
HOTLINE
产品经理不是经理
慕无忌5022713
onemoo
慕的地6079101
相关分类