-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathParcel7.java
More file actions
52 lines (37 loc) · 1.07 KB
/
Parcel7.java
File metadata and controls
52 lines (37 loc) · 1.07 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
package innerclasses;
/**
* RUN:
* javac innerclasses/Parcel7.java && java innerclasses.Parcel7
* OUTPUT:
* , int i = 11
* MyContents, int i = 11
*/
public class Parcel7 {
public Contents contents()
{
return new Contents() {
private int i = 11;
public int value() { return i; }
public String toString() { return getClass().getSimpleName() + ", int i = "+i; }
};
}
public static void main(String[] args) {
Parcel7 p = new Parcel7();
Contents c = p.contents();
System.out.println(c);
Parcel7b.main(args);
}
}
class Parcel7b {
class MyContents implements Contents {
private int i = 11;
public int value() { return i; }
public String toString() { return getClass().getSimpleName() + ", int i = "+i; }
}
public Contents contents() { return new MyContents(); }
public static void main(String[] args) {
Parcel7b p = new Parcel7b();
Contents c = p.contents();
System.out.println(c);
}
}