The official documentation says it is not possible, but it is getting created. How?
As with instance methods and variables, an inner class is associated with an instance of its enclosing class and has direct access to that object's methods and fields. Also, because an inner class is associated with an instance, it cannot define any static members itself.
// outer class
class OuterClass
{
// nested class
class StaticNestedClass
{
static int a;
static void hi(){
System.out.println("inside hi");
}
void display()
{
a = 9;
System.out.println("inner a = " + a);
hi();
}
}
}
// Driver class
public class StaticNestedClassDemo
{
public static void main(String[] args)
{
OuterClass outer = new OuterClass();
OuterClass.StaticNestedClass inner = outer.new StaticNestedClass();
// all these works
inner.hi();
OuterClass.StaticNestedClass.hi();
}
}