Search code examples
javaprogram-entry-pointpublic

Why main method is marked as public?


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

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

"The method is static because otherwise there would be ambiguity: which constructor should be called?"

But, can anyone can explain why it is declared public always?


Solution

  • The initialization software that starts your program must be able to see main so that it can call it.