class Example {
public static void main(String[] args) {
Child child = new Child();
} } //main
} } // example
class Parent{
String nation;
Parent() {
this ("South Korea");
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 ("Hong Gil-dong");
System.out.println("Child() call");
}
Child(String name) {
this.name = name;
System.out.println("Child(String name) call");
}
} } // class child
When you create and run it like this, main
just created a new object called child
, but I don't know why all println
works. I don't understand the order either.
Finished
© 2024 OneMinuteCode. All rights reserved.