public class Day
{ private int y, m, d;
private Date date;
public Day(int year, int month, int date)
{ y = year -1900;
m = month - 1;
d = date;
date = new Date(y, m, d);
}
public int dayBetween(Day day)
{ }
}
上面是你的程序
public class Day
{ private int y, m, d;
private Date date;
public Day(int year, int month, int day1)
{ y = year -1900;
m = month - 1;
d = day1;
date = new Date(y, m, d);//这个Date类的构造方法是被反对的
}
public int dayBetween(Day day)
{ retrun 0; }
}
以下是java 文档中对这个构造方法的说明
Date()(int year, int month, int date) Deprecated. As of JDK version 1.1, replaced by Calendar.set(year + 1900, month, date)
or GregorianCalendar(year + 1900, month, date)
.