parcel1.java

来自「think in java TIJ-3rd-edition-code.zip」· Java 代码 · 共 33 行

JAVA
33
字号
//: c08:Parcel1.java
// Creating inner classes.
import com.bruceeckel.simpletest.*;

public class Parcel1 {
  class Contents {
    private int i = 11;
    public int value() { return i; }
  }
  class Destination {
    private String label;
    Destination(String whereTo) {
      label = whereTo;
    }
    String readLabel() { return label; }
  }
  // Using inner classes looks just like
  // using any other class, within Parcel1:
  public void ship(String dest) {
    Contents c = new Contents();
    Destination d = new Destination(dest);
    System.out.println(d.readLabel());
  }  
  public static void main(String[] args) {
    SimpleTest monitor =
      new SimpleTest("Parcel1");
    Parcel1 p = new Parcel1();
    p.ship("Tanzania");
    monitor.expect(new String[] {
      "Tanzania"
    });
  }
} ///:~

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?