The reason why you cannot have static (non-constant) members in non-static inner classes is because of the following.
An instance of a non-static inner class belongs to an instance of its enclosing class; it has a reference to the instance of its enclosing class that it belongs to. The following example demonstrates that.
As you can see, the Inner objects are created in the context of a specific Example object, and they can access the
name member variable of the Example object that they belong to.
If it would be possible to add a static member variable to Inner, then it would be unclear what exactly this means. Should it mean that there is only one instance of that variable for all Inner classes, no matter what Example object they belong to? Or should it mean that there is one instance of that variable per Example object, which is shared between all Inner objects that are for the same Example object?
To avoid this ambiguity, the designers of the
Java language decided that it should not be possible to have static members in a non-static inner class.