标签:
package com.mufeng.thetenthchapter; public class Parcell2 { class Contents { private int i = 11; public int value() { return i; } } class Destination { private String label; public Destination(String whereTo) { // TODO Auto-generated constructor stub label = whereTo; } String readLabel() { return label; } } public Destination to(String s) { return new Destination(s); } public Contents contents() { return new Contents(); } public void ship(String dest) { Contents c = contents(); Destination d = to(dest); System.out.println(c.value()); System.out.println(d.readLabel()); } public static void main(String[] args) { Parcell2 p = new Parcell2(); p.ship("Tasmania"); System.out.println("--------我是分割线----------"); Parcell2 q = new Parcell2(); Parcell2.Contents c = q.contents();// (或者 q.new Contents()) Parcell2.Destination d = q.to("Borneo");// (或者 q.new // Destination("Borneo")) System.out.println(c.value()); System.out.println(d.readLabel()); } }
11 Tasmania --------我是分割线---------- 11 Borneo
标签:
原文地址:http://blog.csdn.net/u013693649/article/details/52002802