[求助]内部类的实例化问题
我写了一个类,内嵌两个类。我想在主函数中实例化最里面的那个类。下面是我写的代码:
class First
{
private int index=100;
class Second
{
private int index=80;
class Third
{
private int index=50;
void print()
{
int index=30;
System.out.println(index);
}
}
}
}
class test
{
public static void main(String[] args)
{
First.Second.Third third = new First.Second.Third();
third.print();
}
}
在编译的时候提示如下错误:{
private int index=100;
class Second
{
private int index=80;
class Third
{
private int index=50;
void print()
{
int index=30;
System.out.println(index);
}
}
}
}
class test
{
public static void main(String[] args)
{
First.Second.Third third = new First.Second.Third();
third.print();
}
}
C:\code\test.java:23: 需要包含 First.Second.Third 的封闭实例
First.Second.Third third = new First.Second.Third();
^
1 错误
请大家帮我看一下,这个问题应该怎么解决。谢谢了。