内部类

来源:互联网 发布:windows安全性确认证书 编辑:程序博客网 时间:2024/04/27 15:38

class Outer
{
 int count_1=100;
 void test()
 {
  Inner iner=new Inner();
  iner.display();
 }
 
 class Inner//如果将内部类类名前加上关键字static,那么内部类将变成外部类
 {
  void display()
  {
   System.out.println("count_1 ="+count_1); 
  }
 }
 public static void main(String args[])
 {
  Outer outer = new Outer();
  outer.test(); 
 }
 
}

原创粉丝点击