Java shouldn't allow static methods within an inner class and yet this code compiles and runs. How is this possible?
class Test{
static int j=20;
public void m1() {
class Inner{
public static void m2() {
System.out.println(j);
}
}
Inner inner = new Inner();
inner.m2();
}
public static void main(String[] args) {
Test obj = new Test();
obj.m1();
}
}