Java Hello World

Source: Internet
Author: User

Helloworld.java is our first program to learn Java, simple can no longer simple, but the principle of the inside and the implementation process everyone knows? Recently in the review of Java Knowledge, specially delve into a share to everyone!

The code to post the HelloWorld is as follows:

Class HelloWorld {    void// definition string s     

Analyze Memory Graphs:

HelloWorld the specific implementation process:

1. Execute Helloworld.java file, generate Helloworld.class bytecode file;

2. The virtual machine executes the Helloworld.class and loads the class into memory (that is, in the class code area of the method area);

3. The virtual machine finds the main method of HelloWorld through the class (the entry method of the program), the access permission is public (publicly available), the virtual machine passes string[] (string array object: Empty array) The address of the type parameter to the main method of args, And in the stack area for the args open memory space, return a void return value;

4. Define a string (the standard class library) type of variable (in the stack space) s,s value is undefined (garbage value, compilation cannot pass);

5. S = "Hello world!", object "Hello world!" Space is created in the constant data area of the method area, which is: Hello world!, the method is: toString (), the variable s holds the object "Hello world!" 's address;

6. The virtual machine finds the System.class class in the standard class library and loads it into memory (that is, in the class code area of the method area), System.out to the standard byte output stream object (), and calls the println () method to print the value of the variable s to the screen.

PS: When the virtual machine calls the Main method, three default objects are created: System.out (standard byte output stream object), system.in (standard byte input stream object), and System.error (standard byte Error stream object).

The above total involves:

1 Java files: Helloworld.java

4 class classes: Helloworld.class, String[].class, String.class, System.class

5 objects: "Hello world!", string[], System.out, system.in, System.error

2 variables: args, S

3 methods: Main (), toString (), println ()

Java Hello World

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.