I was completely blown away after I made a static member in Method local inner class, I am wondering what might be its use case as the scope of MLIC member is only inside the method in which they are defined. Are MLIC's implicitly static? Then how am I able to access instance members from outer class?
class Test {
int i = 8;
//instance method
void m() {
//method local inner class
class I1{
static int x2 = 2; //static variable declaration
public void main() {
System.out.println(i); //outer class instance variable accessible
}
static void print() { //static method declaration
System.out.println("I am a static method in MLIC");
}
}
I1 i1 = new I1();
i1.main();
I1.print();
}
}