Why the main program in Java is put into a class?

后端 未结 9 551
囚心锁ツ
囚心锁ツ 2020-12-28 17:37

Why does the main method have to be put into a class? I understand the main ideas of OOP but I cannot get why the main program is defined within a class. Will such a class i

9条回答
  •  北荒
    北荒 (楼主)
    2020-12-28 18:21

    When the Java language was designed, the notion that everything must be an object was a point of dogmatism. (though they left in a few primitive types). These days you could perhaps design a language that uses a closure -- even one outside any class -- instead.

提交回复
热议问题