稍复杂点建立集合,对输入的月份在集合中是否包含进行判断。作者: 刘治广 时间: 2013-5-29 17:38
class SwitchTest
{
public static void main(String[] args)
{
//定义一个月份
int month = 3;
switch(month) {
case 1:
case 2:
case 12:
System.out.println(month+"月是冬季");
break;
case 3:
case 4:
case 5:
System.out.println(month+"月是春季");
break;
case 6:
case 7:
case 8:
System.out.println(month+"月是夏季");
break;
case 9:
case 10:
case 11:
System.out.println(month+"月是秋季");
break;
default:
System.out.println("数据有误");
break;
}
}