-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassInitDemo.java
More file actions
56 lines (47 loc) · 1.32 KB
/
Copy pathClassInitDemo.java
File metadata and controls
56 lines (47 loc) · 1.32 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
import sun.misc.Unsafe;
/**
* @author xjn
* @since 2020-03-02
*/
public class ClassInitDemo {
final String result;
private static final char value[] = new char[10];
private static ThreadLocal threadLocal;
public ClassInitDemo(String x, String y) {
this.result = add(x, y);
}
public String add(String x, String y) {
threadLocal.remove();
return x + y;
}
static class SubClass extends ClassInitDemo {
String z;
public SubClass(String x, String y, String z) {
super(x, y);
this.z = z;
}
public String add(String x, String y) {
return super.add(x, y) + z;
}
}
public static String appendStr(String s) {
s += "bbb";
System.out.println(s);
return s;
}
public static Integer test(Integer a) {
a += 1;
return a;
}
public static void main(String[] args)throws Exception {
// System.out.println(new SubClass("A", "B", "C").result);
// String s = new String("aaa");
// String ns = appendStr(s);
// System.out.println("s:" + s.toString());
Unsafe unsafe = Unsafe.getUnsafe();
Integer a = 1;
Integer test = test(a);
System.out.println("a:" + a);
System.out.println("test:" + test);
}
}