package zhidao;
import java.util.Calendar;
public class Month {
public static void main(String[] args){
Calendar c=Calendar.getInstance();
int month = c.get(Calendar.MONTH) + 1;
if(month >= 1 && month <=3){
System.out.println("现在是" + month + "月");
System.out.println("现在是春天");
}else if(month <= 6){
System.out.println("现在是" + month + "月");
System.out.println("现在是夏天");
}else if(month <= 9){
System.out.println("现在是" + month + "月");
System.out.println("现在是秋天");
}else if(month <= 12){
System.out.println("现在是" + month + "月");
System.out.println("现在是冬天");
}else{
System.out.println("系统时间错误");
}
}
}
Calendar c=Calendae.getInstance();
int month = c.get(Calendar.MONTH) + 1;
switch(month)
{
case 2
case 5<=month<8:
System.out.println("夏天");
case 8<=month<11:
System.out.println("秋天");
case 11<=month<1:
System.out.println("冬天");
default:语句;
}
public class test1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Calendar c = Calendar.getInstance();
int m= c.get(Calendar.MONTH)+1;
switch (m) {
case 1:
case 2:
case 3:
System.out.println("现在是春天");
break;
case 4:
case 5:
case 6:
System.out.println("现在是夏天");
break;
case 7:
case 8:
case 9:
System.out.println("现在是秋天");
break;
case 10:
case 11:
case 12:
System.out.println("现在是冬天");
break;
default:
break;
}
}
}