SE450: Constructors: Object Construction [1/32] |
Don't let the "this" reference escape during construction
file:Main.java [source] [doc-public] [doc-private]
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
package subclass.constructor; class Main { public static void main(String[] argv) { new X(); new X(); } } class O { int i, j; { i = 42; System.err.println("i"); } O() { System.err.println("O"); } { j = 27; System.err.println("j"); } } class X extends O { int k; X() { System.err.println("X"); } { k = 27; System.err.println("k"); } }