public class BirthdayTest |
{ |
int year,month,day; //成员变量 |
Birthday gt; |
public BirthdayTest( int year){ //方法重载 |
this .year=year; //用this关键字来初始化 |
} |
public BirthdayTest( int year, int month){ //方法重载 |
this (year); //用this关键字作为参数来传值 |
this .month=month; |
} |
public BirthdayTest( int year, int month, int day){ //方法重载 |
this (year,month); //用this关键字作为参数来传值 |
this .day=day; |
} |
|
public static void main(String[] args){ |
|
BirthdayTest birthday= new BirthdayTest( 2017 , 7 , 18 ); |
System.out.println( "出生年月日" +birthday.year+ "年" +birthday.month+ "月" +birthday.day+ "日" ); |
} |
}; |