Getting Started with Java--hello world!

Source: Internet
Author: User

public class HelloWorld {??    public static void Main (string[] args) {??        System.out.println ("Hello World");??    }}

File name is Helloworld.java

1. Defining classes

Class is the keyword used to define the classes, followed by the name of the class (HelloWorld). Java programs stipulate that all program code is defined in the class. There is a public keyword in front of the class , which is a Java modifier that indicates that the HelloWorld class is an exposed class.

2. Defining chunks

Use {} to define chunks in your program to differentiate program code ranges.

3. define the main() method

The starting point of program execution is the program entry point, and the starting point of Java program execution is the main() method. The main() method above: public static void Main(String[] args) {}

The main () method is public decorated, indicating that it can be executed publicly by the JVM, which means that the JVM can be called without generating a class instance. void indicates no return value. string[] args can get the user-specified command-line arguments when executing a program.

4. Write a description

The first line in main describes:

System.out.println("HelloWorld");

A description is a line of instructions in a programming language, which is simply "a word" in a program. Notice the end of each sentence to use a semicolon (;), the function of this sentence is to ask the system output device display a line of text HelloWorld.

Getting Started with 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.