class Car2 {
String color;
String gearType;
int door;
Car2() {
this("white", "auto", 4);
}
Car2(String color) {
this(color, "auto", 4);
}
Car2(String color, String gearType, int door) {
this.color = color;
this.gearType = gearType;
this.door = door;
}
}
Car(String c, String g, int d) {
color = c;
gearType = g;
door = d;
}
위 코드에서는 this 생략 가능
Car(String color, String gearType, int door) {
this.color = color;
this.gearType = gearType;
this.door = door;
}
위 코드에서는 생성자의 매개변수와 인스턴스 변수 이름이 같기 때문에 this로 구분