本帖最后由 赵燕燕 于 2011-12-12 00:04 编辑
import java.util.*;
class CalendarDemo
{
public static void main(String[] args)
{
Calendar c=Calendar.getInstance();
c.set(2011,10,26);
printCalendar(c);
}
public static void printCalendar(Calendar c)
{
String[] week={"","星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
int index=c.get(Calendar.DAY_OF_WEEK);
System.out.println(index);
System.out.println(week[index]);
}
}
//查表法查看日期时,日期数组为什么要写成这样 String[] week={"","星期日","星期一","星期二","星期三","星期四","星期五","星期六"}; 怎么得到的? |
|