I understand that an Inner Class it's non-static and a static method from the Outer Class can't reference it.
I have this code, that doesn't work, and I understand why that doesn't work.
class OuterClass {
class InnerClass{}
public static void outherMethod() {
InnerClass i = new InnerClass();
}
}
But then I have this other code, that DOES work, but I don't understand why it's different from the first one. Why does it work?
class OuterClass {
class InnerClass{}
public static void outherMethod() {
InnerClass i = new OuterClass.new InnerClass();
}
}
Thanks in advance!
EDIT: it's not duplicated because it isn't the same question. I'm not asking about static nested classes, I'm asking about static methods and inner classes