-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathParcel5.java
More file actions
40 lines (29 loc) · 844 Bytes
/
Parcel5.java
File metadata and controls
40 lines (29 loc) · 844 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
40
package innerclasses;
/**
* RUN:
* javac innerclasses/Parcel5.java && java innerclasses.Parcel5
* OUTPUT:
* PDestination, label = Tasmania
*/
public class Parcel5 {
public Destination dest(String s) {
class PDestination implements Destination {
private String label;
private PDestination(String whereTo) {
label = whereTo;
}
public String readLabel() {
return label;
}
public String toString() {
return getClass().getSimpleName() + ", label = "+label;
}
}
return new PDestination(s);
}
public static void main(String[] args) {
Parcel5 p = new Parcel5();
Destination d = p.dest("Tasmania");
System.out.println(d);
}
}