IT/자바

생성자2

Beautifulkim 2018. 4. 26. 12:07

//private 생성자이기 때문에 객체생성 못함

Math mt = new Math();



myutil 패키지 내용


package myutil;


public class MyDate4 {

int year, month, day;

public MyDate4() {

// TODO Auto-generated constructor stub

}


public MyDate4(int year, int month, int day) {

//super(); //아버지를 부르는 메소드

this.year = year;

this.month = month;

this.day = day;

}


public MyDate4(int year, int month) {

super();

this.year = year;

this.month = month;

}


public MyDate4(int year) {

super();

this.year = year;

}


public int getYear() {

return year;

}

// 멤버변수에 세팅

public void setYear(int year) {

this.year = year;

}


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;

}

}