我在Java中遇到以下问题,如果在外部类的方法中声明了内部类,如何初始化内部类的实例?在以下情况下,我遇到了编译错误。非常感谢。
class Outer {
public int a = 1;
private int b = 2;
public void method(final int c){
int d = 3;
class Inner{
private void iMethod(int e){
System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println("c = " + c);
System.out.println("e = " + e);
}
}
}
public static void main (String[] args){
Outer outer = new Outer();
Outer.Inner inner = outer.new Inner();// there is an compile error here
}
}