自定义日期类,要求有年月日三个成员变量有带参数的构造方法拷贝构造方法可以20170328的形式输出日期对象 20
展开全部
public class DataTest {
public static void main(String[] args) {
MyDate t1 = new MyDate(2017,04,26);
t1.showDate();
MyDate t2 = new MyDate(t1);
t2.showDate();
}
}
class MyDate{
public int year;
public int month;
public int day;
public MyDate( int a,int b,int c){
year = a;
month = b;
day = c;
}
public MyDate(MyDate t){
super();
this.year = t.year;
this.month = t.month;
this.day = t.day;
}
public void showDate(){
String str = " " + year + month + day;
System.out.println(str);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询