Among them, public is a permission modifier, which means that any class or object can access this method, static means that it is a static method, and the code in the method is stored in a static storage area. As long as the class is loaded, you can use this method without instantiation.
You can access it directly through the class name. main()。 When the jvm starts, it looks for the entrance address of the method according to the signature of the calling method (it must be decorated with public and static, the return value is void, and the method parameters are string arrays).
If it is found, it will be executed. If not found, it will be reported as an error. Void means that the method has no return value. mian is a special method recognized by jvm and is the entrance method of the program. The string array parameter args provides a way for developers to interact with programs in the command line state.
Extended data
A detailed description of the main () method in JAVA
There is a main () method in the HelloWorld class, indicating that this is a java application, and the running program is started directly through the JVM. Since it is a class, java allows classes not to be bound by common keywords. Of course, the definition of a class can only be limited to public or unlimited keywords (default).
The declaration of this main () method is: public static void main (String args []). It must be defined in this way, which is the specification of Java. The reason for this definition is related to the operation of JVM.
When there is a main () method in a class, executing the command "java class name" will start the virtual machine to execute the main method in the class.
Because the JVM will call the main method first when running this Java application, it will not instantiate the object of this class, but call it directly through the class name, so it needs to be limited to public static. (class name. main())
For the main method in java, the jvm has restrictions and cannot have a return value, so the return value type is void.
There is also an input parameter in the main method, and the type of the input parameter is String[], which is also the specification of java. There must be an input parameter in the main () method, and the type must be String[]. As for the name of the string array, this can be set by yourself. By convention, the name of this string array is generally the same as the mian parameter name in the example of sun java specification, and it is named args.
Therefore, the definition of the main () method must be: "public static void main (string array parameter name [])".