首页 > 编程语言 > 详细

java----内部类

时间:2017-09-08 22:20:20      阅读:211      评论:0      收藏:0      [点我收藏+]

public class Parcell
{
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;
}
}
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)
{
Parcell p=new Parcell();
p.ship("Tasmania");
}

}
/*
* 将Contents,Destination,类置于Parcell类中。
*
*
* 当我们在ship()方法里使用内部类的时候,与使用普通类没什么不同
*
* -----摘自《Java编程思想》
* */
*/

java----内部类

原文:http://www.cnblogs.com/fanzhengzheng/p/7496582.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!