カレンダークラスCalendarを使用して、任意の年の2月に何日あるかを求めます.
3554 ワード
1.Calendarクラスの概要2.Calendarの構造方法3.任意の年2月の取得日数
カレンダークラスCalendarを使用して、任意の年の2月に何日あるかを求めます.
任意の年の2月の取得日
カレンダークラスCalendarを使用して、任意の年の2月に何日あるかを求めます.
任意の年の2月の取得日
:
1.
2. , , 2
0 , 2 3 , 1
3.
4.
class test{
public static void main(String[] args){
//
Scanner sc = new Scanner(System.in);
//
System.out.println(" :");
int year = sc.nextInt();
//
Calendar c = Calendar.getInstance();
//
c.set(year, 2, 1);// 3 1
//
c.add(Calendar.DATE, -1);
//
System.out.println(c.get(Calendar.DATE));
}
}