-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathAnonymousClass.java
53 lines (43 loc) · 1.23 KB
/
AnonymousClass.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
44
45
46
47
48
49
50
51
52
53
public class AnonymousClass {
private final String field = "outer field";
private interface I {
void f();
}
void member() {
final int local = 42;
I i = new I() {
private final String field = "inner field";
@Override
public void f() {
System.out.println(AnonymousClass.this.field);
System.out.println(field);
System.out.println(local);
}
};
i.f();
}
public static void main(String[] args) {
final String local = "local";
I i = new I() {
int field = 3;
@Override
public void f() {
System.out.println(local);
System.out.println(field);
I j = new I() {
int field = 4;
@Override
public void f() {
System.out.println(local);
System.out.println(field);
}
};
j.f();
}
};
i.f();
i = new I() { public void f() { System.out.println(5); } };
i.f();
new AnonymousClass().member();
}
}