Why can't a top level class be static in Java?

前端 未结 8 1345
礼貌的吻别
礼貌的吻别 2020-12-04 07:30

Can\'t find a satisfactory answer anywhere.

8条回答
  •  失恋的感觉
    2020-12-04 08:09

    We can't declare outer (top level) class as static because the static keyword is meant for providing memory and executing logic without creating Objects, a class does not have a value logic directly, so the static keyword is not allowed for outer class.

提交回复
热议问题