Writing the first Java program

Source: Internet
Author: User

public class hello{    //is the starting point of the program, and all programs start running public    static void Main (String args[])    {        System.out.println ( "Hello world!");}    }

Save the above code as a Hello.java file and enter [Javac Hello.java] on the command line (the JDK is installed and the installation path is added to the environment variable). If there is no error, then enter [Java Hello].

Command line output result: Hello world!

Note that if you declare a class as public, you also take the file name sing Woo the same name as the class. In other words, in a Java file, there can be at most one public class, otherwise. java files cannot be named.

In all Java application, all programs run from public static void main (String args[]).

The compilation and operation of Java code is as follows:

Writing the first Java program

Related Article

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.