Let's begin by understanding the default definition format for the main () method in Java:
public static void Main (string[] args) {
}
The 1.main method is the entrance of the program execution, except that the parametric of the args can be changed, and the other cannot be changed.
Why is 2.JVM so defined?
Because the JVM is running this Java application, it first calls the main method, which does not instantiate the object of the class, but is called directly through the class name, so it needs to be restricted to public static.
The JVM specifies that a return value cannot be returned, so the return value type is void.
The main () method must have an entry parameter, the type must be string[], and the formal parameter name defaults to AGRs.
3. A program can have only one public static void main (string[] args) {}, but there can be an infinite number of overloaded main (), such as:
4. The following is an introduction to args:
Let's look at the diagram below.
This means that the JVM does not pass any parameters to the JVM when it calls the main () method, but it is also easy to understand that the JVM does not know what useful parameters the main () method requires.
5. But there are two ways we can pass a parameter to the main () method
The first kind: look:
The second kind: right mouse button, click Run as Select Run configurations select arguments to pass the parameter,
The main role of 6.args:
The Main method parameter is to accept the command line input parameters, the formal parameter will be used to accept the role of the information passed.
On the knowledge point of the args of main () in Java