程序代码:
/**
需求:根据月份,输出这个月份所属的季节
12,1,2为春季;3,4,5为夏季;6,7,8为秋季;9,10,11为冬季
*/
class SwitchTest
{
public static void main(String[] args)
{
int num=3;
Switch(num)
{
case 12:
case 1:
case 2:
System.out.print(num+"现在的季节是春季");
break;
case 3:
case 4:
case 5:
System.out.print(num+"现在的季节是夏季");
break;
case 6:
case 7:
case 8:
System.out.print(num+"现在的季节是秋季");
break;
case 9:
case 10:
case 11:
System.out.print(num+"现在的季节是冬季");
break;
default:
System.out.print("nono");
}
}
}
程序错误:
SwitchTest.java:10: 需要 ';'
Switch(num)
^
SwitchTest.java:12: 单个 case:
case 12:
^
2 错误
不知道那里出错了,就是报上面的错误,请兄弟们帮帮忙呵呵 |