风雨无阻

JAVA内部类

public class Aqiang {

// 静态内部类
 static class Test
 {
  private int i ;
  public Test()
  {
   i = 2;
  }
 }
 class TestB
 {
  private int i = 3;
 }

 private int j;

 public static void main(String args[]) {
  
  // 静态内部类(Inner Class)意味着1创建一个static内部类的对象,不需要一个外部类对象
  Aqiang.Test test = new Aqiang.Test();
  System.out.println("test" + test.i);
  
  // 而非静态内部类,需要选创建一个外部类对象,然后才能创建内部内对象
  Aqiang aqiang = new Aqiang();
  Aqiang.TestB tb = aqiang.new TestB();
  System.out.println("testb" + tb.i);

 }
}

posted on 2008-03-18 23:28 秋枫故事 阅读(124) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 
<2008年3月>
2425262728291
2345678
9101112131415
16171819202122
23242526272829
303112345

导航

统计

常用链接

留言簿(2)

随笔分类

随笔档案

新闻档案

搜索

最新评论

阅读排行榜

评论排行榜