2. Hello Word Explanation

Source: Internet
Author: User

2.1 Writing a program

Steps

Steps 1: in the "Java Project ( menu item )" left-click on

Steps 2: in the "Project Name: ( edit )" left-click on ( in "New Java Project" )

Steps 3: in the "Project Name: ( edit )" on keyboard input ( in "New Java Project" ) [Demo010]

Steps 4: in the "&next ( button )" left-click on ( in "New Java Project" )

Steps 5: in the "Finish ( button )" left-click on ( in "New Java Project" )

Steps 6: in the "Package ( menu item )" left-click on

Steps 7: in the "Name: ( edit )" left-click on ( in "New Java package" )

Steps 8: in the "Name: ( edit )" on keyboard input ( in "New Java package" ) [Com.zjk.helloworld]

Steps 9: in the "Finish ( button )" left-click on ( in "New Java package" )

Steps Ten: in the "Class ( menu item )" left-click on

Steps One : in the "Name: ( edit )" left-click on ( in "New Java Class" )

Steps : in the "Name: ( edit )" on keyboard input ( in "New Java Class" ) [HelloWorld]

Steps : in the "Finish ( button )" left-click on ( in "New Java Class" )

Step : Enter the code:

Public staticvoid main (string[] args) {

????????

???????? System. out. println ("Hello world!") );

????}

?

2.2 Running the program

?

??

Steps

Right -click "Run as ( menu item )" in the code area

Steps 1: in the "Run as ( menu item )" left-click on

Steps 2: in the "1 Java application Alt+shift+x, J ( menu item )" left-click on

?

? 2.3 Program Explanation

One of the simplest Hello word programs, it only sends a message to the console window:

?

Public classHelloWorld {

????

????

???? Public staticvoid main (string[] args) {

????????

???????? System. out. println ("Hello world!") );

????}

?

}

?

First line:

Key Words Public called an access modifier, which is used for the level of access to this code by other parts of the console program.

Key Words class indicate that Java all of the content in the program is contained in this class (here, the class is simply a container for loader logic, and the program logic is defined as the behavior of the program.) )。

Key Words class immediately following the class name. naming rules for Java:

    1. ' _ ' ' $ ' symbol
    2. If a name consists of multiple words, the first letter of each word should be capitalized
    3. java public class

Note: The name of the source file must be the same as the name of the public class, and . Java as the extension.

?

This procedure can be seen:

    • Java is case sensitive. If there is a case-spelling error (for example, if main is spelled as Main), then the program will not run.
    • In Java, each part of the program is divided into curly braces.

?

2. 4 Notes

?

annotations are channels of communication between programmers. When we appreciate the ancient poetry, we will inevitably encounter some abstract difficult words, words, sentences, however, books are generally annotated, this is to allow readers to better imagine the scene of creation, better to understand the feelings of the creator, and then put yourself in the intoxicated. The reader naturally praises the word. I've always thought that code like poetry, writing code is like reciting poetry. But the simple code does not completely make the idea of the program understood by others, and even worse, it can be cursed. Some of the parameters in the code, like the words mentioned above , aresome lines in the code, like the words mentioned above , some functions in the code, or some blocks of code, like the " sentence "mentioned above. With the aid of annotations, the reader can understand the implementation of the Code of the idea, you do not have to find someone to ask, greatly save time costs, but also more focus on the work.

?

Java There are three ways to annotate

    1. '//' single-line comment: Its comment content from/to the end of the bank
    2. /* * * Multi-line Comment: Its comment content from/* to */end
    3. /** */Document Comment: You can generate an API document with comments on the previous line of the method or class name

2. Hello Word Explanation

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.