码迷,mamicode.com
首页 > 编程语言 > 详细

java----内部类

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

标签:rgs   class   static   使用   不同   adl   arc   sys   main   

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----内部类

标签:rgs   class   static   使用   不同   adl   arc   sys   main   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!