1 //: Parcel1.java
2 // 研究内部类(inner class)
3
4 package cn.skyfffire;
5
6 public class Parcel1 {
7 /* 第一个InnerClass */
8 static class Contents {
9 private int i = 11;
10
11 public int value() {
12 return i;
13 }
14 }
15 /* 第二个InnerClass */
16 static class Destination {
17 private String label;
18
19 Destination(String whereTo) {
20 label = whereTo;
21 }
22
23 String readLabel() {
24 return label;
25 }
26 }
27
28 /* 两个内部类获取器 */
29 static Contents makeContents() {
30 return new Contents();
31 }
32
33 static Destination makeDestination(String str) {
34 return new Destination(str);
35 }
36
37 public static void main(String[] args) {
38 Parcel1.Destination d = Parcel1.makeDestination("hahaha");
39 Parcel1.Contents c = Parcel1.makeContents();
40
41 System.out.println(c.value());
42 System.out.println(d.readLabel());
43 }
44 }