第4章 内部类(学生版).docVIP

  • 1
  • 0
  • 约4.34千字
  • 约 6页
  • 2016-12-03 发布于河南
  • 举报
第4章 内部类(学生版)

成员内部类 (1)可以访问直接外部类的成员;包括私有;持有外部类的引用; (2)外部类要访问内部类必须建立内部类对象; (3)直接内部类中的成员,Outer.Inner in=new Outer().new Inner();(4)外部类和内部类和成员方法内有相同的成员;class Outer { private int x = 3; class Inner//内部类 { //int x = 4; void function() { //int x = 6; System.out.println(innner :+Outer.this.x); } } /**/ void method() { Inner in = new Inner(); in.function(); } } class InnerClassDemo { public static void main(String[] args) { Outer out = new Outer(); out.method(); //直接访问内部类中的成员。 // Outer.Inner in = new Outer().new Inner(); // in.function(); } } class OuterStatic{ sta

文档评论(0)

1亿VIP精品文档

相关文档