Originally posted by victor gu:
public class Outer{
public class Inner{
}
static void aMethod(){
OuterClass ot=new OuterClass();
Inner in1=ot.new Inner(); //no problem
Inner in2=Outer.new Inner(); //error
}
}
Since there is not this reference in a static method, can we use class name Outer to do the job?
I am wondering why the second object creation failed? Any thoughts?
Victor
In your code, Inner is not static member of Outer class, you need to have a enclosing instance of Outer before you can create instance of Inner.