次のメインメソッドをコンパイルできないようです:
public class MainMethod {
public static void main(String []args){
InnerizationClass outer = new InnerizationClass();
InnerizationClass.StaticInnerClass inner = outer.StaticInnerClass(); //#1
System.out.println(inner.getOuterClassVar());
System.out.println(new InnerizationClass().locInnrMeth());
}
}
これは InnerizationClass クラスです。
public class InnerizationClass {
String outerClassVar = "Outer Catism";
static String outerClassVarStat = "Outer Static Catism";
public static class StaticInnerClass{
String innerClassVar = "Catism";
public String getInnerClassVar(){
return this.innerClassVar;
}
public String getOuterClassVar(){
return InnerizationClass.outerClassVarStat;
}
}
public String locInnrMeth(){
class MethodLocalInnerClass{
String methodLocalInrCls = "Method Local Catism";
void printInner(){
System.out.println(InnerizationClass.this.outerClassVar);
}
}
return new MethodLocalInnerClass().methodLocalInrCls;
}
public String getStaticOuterVar(){return null;}
}
メインメソッドの #1 から次のエラーが発生しています。
MainMethod.java:6 qualified new of static class
InnerizationClass.StaticInnerClass inner = outer.new StaticInnerClass();
1 error;