package wzt;
import java.util.Calendar;
public class Sw1 {
public static void main(String[] args) {
Calendar instance = Calendar.getInstance();
int i = instance.get(Calendar.DAY_OF_WEEK);
String wk="";
if(i==2){
wk="星期一";
}else {
if(i==3){
wk="星期二";
} else {
if(i==4){
wk="星期三";
}else {
if (i==5){
wk="星期四";
}else {
if (i==6){
wk="星期五";
}else {
if (i==7){
wk="星期六";
}else {
wk="星期日";
}
}
}
}
}
}
System.out.println(wk);
switch (i) {
case 2:
wk="星期一";
break;
case 3:
wk="星期二";
break;
case 4:
wk="星期三";
break;
case 5:
wk="星期四";
break;
case 6:
wk="星期五";
break;
case 7:
wk="星期六";
break;
default:
wk="星期日";
break;
}
System.out.println(wk);
}
}
if、switch、Calendar、实现星期几操作
于 2022-02-12 14:59:17 首次发布