本帖最后由 杨兴庭 于 2013-7-24 21:07 编辑
public static void main(String[] args)
{
Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH)+1;
int day =c.get(Calendar.DAY_OF_MONTH);
//int week = getWeek(c.get(Calendar.DAY OF WEEK));
//System.out.println(year+"年"mouth+"月"day+"日"+week);
int week = c.get(c.get(Calendar.DAY_OF_WEEK));
System.out.println(year+"年"+month+"月"+day+"日"+getWeek(week));
}
//public static int getWeek(int i)
public static String getWeek(int i)
{
String[] weeks = {"","星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
return weeks;
}
这个代码抛出异常的原因是由于什么导致的?
抛出的是 java.lang.ArrayIndexOutOfBoundsException 这个应该是角标越界啊
|