设计日期类,每个日期对象都可以描述年月日信息
class Time{
private int years ;
private int month;
private int day;
public int getYears(){
return years;
}
public void setYears(int years){
this.years = years;
}
public int getMonth(){
return month;
}
public void setMonth(int month){
this.month = month;
}
public int getDay(){
return day;
}
public void setDay(int day){
this.day = day;
}
}
public class TimeTest{
public static void main(String []args){
Time T = new Time();
System.out.println(" "+T.getYears()+T.getMonth()+T.getDay());
}
}
收获:
- get是有返回值的 set 无返回值