The application will all be contained within one class called HelloWorld.
The class is defined as follows:
1: public class HelloWorld
2: {
3: public static void main(String[] args)
4: {
5: System.out.println("Hello World !");
6: }
7: }
Open up a text editor and copy the class declaration above excluding
the line numbering. Save the file as HelloWorld.java (note the placing
of the capital letters).
Now stepping through each of the lines in the code:
-
Line 1 - This line declares a public class called HelloWorld.
-
Line 2 - This is the opening brace for the class's body
-
Line 3 - This line declares the void main method for the class. Execution
of the application will start here.
-
Line 4 - This is the opening brace for the method's body
-
Line 5 - This line prints the line "Hello World !" to the console. It does
this by making a call through the System class. The System class provides
access to several System functions including writing to the console.
-
Line 6 - This is the closing brace for the the method's body
-
Line 7 - This is the closing brace for the class's body