-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathInitializer.java
44 lines (34 loc) · 998 Bytes
/
Initializer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class Initializer {
int i = 42;
static { System.out.println("Static"); }
{ System.out.println(i); }
{ System.out.println("After"); }
Initializer(int i) {
System.out.println("Inner constructor");
System.out.println(i);
}
Initializer(String s) {}
Initializer() {
this(27);
System.out.println("Outer constructor");
}
public static void main(String[] args) {
Initializer i = new Initializer();
i = new Initializer();
i = new Subclass();
i = new Subclass();
}
static class Subclass extends Initializer {
int j = 24;
{ System.out.print("Subclass "); System.out.println(j); }
{ System.out.println("Subclass after"); }
Subclass(int n) {
super();
System.out.println("Subclass inner constructor");
}
Subclass() {
this(0);
System.out.println("Subclass outer constructor");
}
}
}