The first Java program

Source: Internet
Author: User

① First Program HelloWorld

1 Packager Myjava; // equivalent to a directory 2 class  3{4public     staticvoid   5    {6         System.out.println ("Hello world!" ); 7     }8 }

② Note:

1. The file name must be the same as the public decorated class name, with. Java as the suffix of the file, but if the defined class is not public decorated, the file name can be different from the class name .

2. There can be multiple classes in a. java file, but there is only one class that is public-decorated. So in a. java file, there are several class classes, and there can be only one class of public

3.java source code files after compiling, a class name corresponds to the generation of a. class file . Whether he is a public modifier or a class that does not have any modifiers.

4. A Java application should contain a main () method, and the signature is fixed, and he is the entry method for the main program. can be defined in any class. is not necessarily in the public-decorated class.

The first Java program

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.