SE450: Constructors: this constructors [2/32] Previous pageContentsNext page

this constructors [source] [doc-public] [doc-private]
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
package subclass.ex8;

public class M {
  public static void main(String[] argv) {
    new B();
    new C();
  }
}
class A {
  A()      {System.out.println("A()");}
}
class B extends A {
  B() {
    this(1);
    System.out.println("B()");
  }
  B(int x) {System.out.println("B(int)");}
}
class C extends B {
  C()      {System.out.println("C()");}
}

Previous pageContentsNext page