class 2222//类名定义错误
{
public static void main(string[] args)//应为String,s要大写
{
//需求2:根据用于指定月份,打印该月份的所属季节
int x=4;
switch(x)
{
case3://case 与 3之间要有空格,下面都是如此
case4:
case5:
System.out.println(x+"春季");
break;
case6:
case7:
case8:
System.out.println(x+"夏季");
break;
case9://
case10://这几处和其它处你用的是中文输入符号
case11://
System.out.println(x+"秋季");
break;
case12:
case1:
case2:
System.out.println(x+"冬季");
break;
default:
Systen.out.println(nono);//System.out.println("nono");
}
修改后能运行的如下:
class aaa
{
public static void main(String[] args)
{
//需求2:根据用于指定月份,打印该月份的所属季节
int x=4;
switch(x)
{
case 3:
case 4:
case 5:
System.out.println(x+"春季");
break;
case 6:
case 7:
case 8:
System.out.println(x+"夏季");
break;
case 9:
case 10:
case 11:
System.out.println(x+"秋季");
break;
case 12:
case 1:
case 2:
System.out.println(x+"冬季");
break;
default:
System.out.println("nono");
break;
}
}
}
C:\Users\Lee\Desktop>java aaa
4春季
|