This is our first program in Java. It will print “Hello World!” to the screen. Being the first program, it is very easy. It is basically used to illustrate the basic syntax and program structure of Java.
This program illustrates the basic program structure in java.
- The lines 1 to 3 are comments.They have no effect on the execution of the program. The are also not necessary.
- The line 4 declares a class which ends at line 10.
- At line 6 the main method starts which ends at line 9. The execution of a java program starts from the main method.
- The statement at line 8 is used to display the output. It prints “Hello World!” to the screen.