class Outer
{
private int num = 4;
class Inter
{
public void show()
{
System.out.print("run show "+num);
}
}
public void method()
{
// 创建内部类方法,调用内部类属性
Inter in = new Inter();
in.show();
}
}
public class demo8
{
public static void main(String[] args)
{
// 创建外部类对象,调用外部类的成员函数method方法
Outer o = new Outer();
o.method();
//创建(外部类意外的)对象访问内部类的方法,并且调用
Outer.Inter inter = new Outer().new Inter();
inter.show();
}
}作者: 星空@3 时间: 2016-7-8 18:57
楼上很给力 加油