If the main method of java does not write public, why is there no Run "Sxh.main ()" when you right-click?

Mar.03,2021
The
main () method must be public


because the fact is that only the public static main (String []) method of public class can be run directly.
another explanation is that when you execute java MainClass at the terminal, only the MainClass method can be accessed with Public and Public, and
because no instance of the class has been created. The parameters of
terminal commands are string arrays, "java MainClass-a b" (["- a", "b"]) and so on, so parameters of type String [] are required.
as for the name main, it inherits from the convention of C language.

Menu