您的位置:首页 > 编程语言 > Java开发

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

2016-07-10 16:37 447 查看
package com.liwin.exercises.internalclass;

public class Parcel1 {

class Contents {

private
int i = 11;

public
int getValue() {return
i;}

}

class Destination {

private String
label;

Destination(String
where) {label =
where;}

String readLabel() {return
label;}

}

public
void ship(String dest) {

Contents c =
new Contents();

Destination d =
new Destination(dest);

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

}

public
static void test() {

Parcel1 p =
new Parcel1();

p.ship("ShangHai");

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  java 内部类