packagemeta;publicclassBirthDate{privateintday=1;privateintmonth=1;privateintyear=1900;publicBirthDate(intday,intmonth,intyear){this.day=day;this.month=month;this.year=year;}publicBirthDate(BirthDatedate){this.day=date.day;this.month=date.month;this.year=date.year;}publicBirthDateaddDays(intadd_days){BirthDatedate1=newBirthDate(this);//构造方法用this作为参数调用date1.day=date1.day+add_days;returndate1;}publicstaticBirthDateaddDays2(BirthDatedate1,intadd_days){date1.day=date1.day+add_days;returndate1;}publicstaticvoidprintDate(BirthDatedate){System.out.println(date.year+""+date.month+""+date.day);}publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubBirthDatedate0=newBirthDate(3,5,1988);printDate(date0);date0=date0.addDays(7);printDate(date0);date0=addDays2(date0,4);printDate(date0);}}第一,构造方法publicBirthDate(BirthDatedate)这种调用自身类类型作为参数究竟是什么意思?目的何在?第二,BirthDatedate1=newBirthDate(this);这里的this又作为了参数目的是什么?
慕虎7371278
RISEBY
相关分类