forked from sermakov/JavaPatternMirea
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsk5.java
More file actions
Latest commit
39 lines (32 loc) · 954 Bytes
/
Copy pathtsk5.java
File metadata and controls
39 lines (32 loc) · 954 Bytes
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
packagesome;
publicclasstsk5 {
staticvoidprt(Objecta) { System.out.println(a); }
publicstaticvoidmain(String[] args) {
//noinspection ConstantConditions
prt(A.a == null);
prt(B.gb() == null);
prt(C.gc() == null);
}
@SuppressWarnings("InstantiationOfUtilityClass")
staticclassA {
staticfinalAa = newA();
privateA() {}
}
staticclassB {
privatestaticBb = null;
privateB() { b = this; }
staticBgb() { returnb; }
}
static {
try {
finalvarb = B.class.getDeclaredFields()[0];
b.setAccessible(true);
b.set(null, B.class.getDeclaredConstructors()[0].newInstance());
} catch (Exceptiona) { a.printStackTrace(); }
}
staticclassC {
privatestaticCc = null;
privateC() {}
staticCgc() { returnc == null ? c = newC() : c; }
}
}