public class helloworld{
public static void Main (string[] args) {
String s;
s = "Hello world!";
System.out.println ("Output:" +s);
}
}
There is only one main class in a class, and the main class must be static, then public, and the main class has no return value.
Java files are first compiled into bytecode files, there are several ways to compile several bytecode files, and then executed by the virtual machine, but in a single-threaded program, the main method is the portal of the virtual machine.
Program at run time, the method area to store: first compiled by the compiler a class of bytecode files, four classes are: Helloworld.class,string[].class,string.class,system.class;
The object contained in the heap contains: 3 method: System.out,system.in,system.error
The stack contains variables, with the args array, but a null array string, and S;
When the virtual runtime accesses the array address s, because s points to "Helloworld", calls the ToString method in the String class, and then the System.out output in the system class.
Personal understanding is not very clear, you are welcome to point out that
Operating mechanism of HelloWorld