[JAVA]简单定义和使用内部类

来源:互联网 发布:淘宝商家商品折扣 编辑:程序博客网 时间:2024/06/18 17:11

package com.liwin.exercises.internalclass;


public class Parcel1 {

class Contents {

private int i = 11;

public int getValue() {return i;}

}

class Destination {

private Stringlabel;

Destination(String where) {label = where;}

String readLabel() {returnlabel;}

}

public void ship(String dest) {

Contents c =new Contents();

Destination d =new Destination(dest);

System.out.println(d.readLabel());

}

publicstatic void test() {

Parcel1 p =new Parcel1();

p.ship("ShangHai");

}

}

0 0