The main () method is the entry method for the Java application, which means that the first method to execute is the main () method when the program is running.
The name must be main;
Must be of public static void type;
You must receive parameters for a string array, and so on.
Public class Demo { publicstaticvoid main (string[] args) { System.out.println () ; System.out.println ("Hello world! "); }}
Output Result:
The demo class has the main () method, which indicates that this is a Java application. Since it is a class, Java allows classes to be non-public keyword constraints, although the definition of a class can only be restricted to public or unrestricted keywords. The declaration of the main () method is: public static void Main (String args[]). This must be defined, which is the Java specification. Public: Access modifier: Static variable, global use, void: Return value type is empty; main: Method name; String args[]: An array of strings passed in. The concrete usage will learn later, let's remember first.
Java Road First step-the first line of Java code