Ex)
class Car {
String color;
Car() {} // 생성자
Car (String c) { // 생성자
color = c;
}
}
Ex)
class Car {
String color;
int door;
Car() {
this("white", 4);
}
Car(String color) {
this(color, 4);
}
Car (String color, int door) {
this.color = color;
this.door = door;
}
}
class CarTest {
public static void main(String[] args) {
Car c1 = new Car();
Car c2 = new Car("blue");
}
}
java의 정석 chapter6