不要网上搜来的答案。。我还是不知道该用什么方法呀
------------------------------------------------------------------------------------
public class Weekday {
public int year;
public int month;
public int day;
public Weekday(int year,int month,int day){
this.year = year;
this.month = month;
this.day = day;
}
public Weekday(){}
public void showWeekday()throws Throwable {
Calendar temp = null;
temp.set(this.year, this.month, this.day);
int x = temp.get(Calendar.DAY_OF_WEEK)-1;
switch(x){
case 0:
System.out.println("星期日");
break;
case 1:
System.out.println("星期一");
break;
case 2:
System.out.println("星期二");
break;
case 3:
System.out.println("星期三");
break;
case 4:
System.out.println("星期四");
break;
case 5:
System.out.println("星期五");
break;
case 6:
System.out.println("星期六");
break;
default:
System.out.println("出错啦");
}
}
}
-------------------------------------------------------------------------------
public class TestWeekday {
public static void main(String args[]) throws Throwable{
Scanner sc = new Scanner(System.in);
Weekday wkd = new Weekday();
wkd.year = sc.nextInt();
wkd.month = sc.nextInt();
wkd.day = sc.nextInt();
wkd.showWeekday();
}
}
------------------------------------------------------------------------------
求大神教导