Operating mechanism of HelloWorld

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.