class Example {
public static void main(String[] args) {
Child child = new Child();
} //main
} // example
class Parent{
String nation;
Parent() {
this("대한민국");
System.out.println("Parent() call");
}
Parent(String nation) {
this.nation = nation;
System.out.println("Parent(String nation) call");
}
} // class parent
class Child extends Parent {
String name;
Child() {
this("홍길동");
System.out.println("Child() call");
}
Child(String name) {
this.name = name;
System.out.println("Child(String name) call");
}
} // class child
이렇게 작성하고 실행하면 main
에서는 그저 child
라는 새로운 객체를 만들었을뿐인데 왜 모든 println
이 작동하는지 모르겠습니다. 그 순서또한 이해가 안갑니다.