创建内部类的对象一定要在外部类的方法中吗,为什么?
class Outer
{
int num = 3;
class Inner
{
int num = 4;
public void show()
{
// int num = 5;
System.out.println("num="+num);
}
}
public void method()
{
Inner i = new Inner();
i.show();
}
public void look()
{
System.out.println("num="+num);
}
}
class Inner01
{
public static void main(String[] args)
{
Outer o = new Outer();
o.look();
}
}
|