Saik0 Saik0 - 3 months ago 12
Java Question

Static option is disabled while creating a new Java class in Eclipse

When I try to create a new Java class in Eclipse, under the "Modifiers" section

static
option is shown as disabled. Why is that?

Answer

The static modifier means a member (be it a field, a method or an inner class) belongs to the class instead of to a specific instance of it. A top level class does not belong to anything (it is not within another class), and thus cannot be static. Only an inner class can be static.

Comments