public class MyDate{
private int year;
private int month;
private int day;
public MyDate(int year
this
this
this
}
public MyDate nextDay(){
int newDay = day +
int newMonth = month;
int newYear = year;
if(newDay >
newMonth ++;
newDay =
}
if(newMonth >
newYear ++;
newMonth =
}
MyDate newDate =
new MyDate(newYear
return newDate;
}
public int getYear(){
return year;
}
public int getMonth(){
return month;
}
public int getDay(){
return day;
}
}
package ch
public class DateTest{
public static void main(String[] args){
MyDate oldDate = new MyDate(
MyDate newDate = oldDate
System
System
System
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/27053.html