Why main method is marked as public?

前端 未结 9 1180
情书的邮戳
情书的邮戳 2020-12-10 08:41

I have a question that why main method is marked as public?

According to an answer on stackoverflow, It is declared as static

9条回答
  •  攒了一身酷
    2020-12-10 08:47

    Public - main method is called by JVM to run the method which is outside the scope of project therefore the access specifier has to be public to permit call from anywhere outside the application.

    From coderanch

提交回复
热议问题