本帖最后由 刘林虎 于 2013-4-4 17:35 编辑
public class aa {
public static void main(String[] args) {
Date2[] days = new Date2[5];
days[0] = new Date2(2013,2,11);
days[1] = new Date2(2012,3,11);
days[2] = new Date2(2012,2,11);
days[3] = new Date2(2013,6,11);
days[4] = new Date2(2013,2,12);
for(int i =0; i <days.length; i++) {
System.out.println(days.toString()+ " ");
} }
}
class Date2 {
int year;
int mouth;
int day;
Date2(int yy, int mm, int dd) {
yy = year;
mm = mouth;
dd = day;
}
public String toString() {
return "year-mouth-day : "+year + "-"+mouth+"-"+day;
}
}
为什么 打印出来都是year-day-mouth: 0-0-0 |