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!