JAVA First Program


How to create your first JAVA Hello World program using NETBEANS 8.0.2 IDE

1.       Click File then New Project
2.       Then select JAVA in the Categories Pane and JAVA Application in the Project Type and Press NEXT button
3.       Then type as HelloWorld in the Project Name and Use Browse button to change the default location for saving your project files. Then Press Finish Button.
4.       NetBeans IDE creates the complete JAVA program for you by adding package, class and method as shown below

              
Now type the below program statement.

System.out.println("Hello World");

Now press on the Execute button. Then this simple program will output by showing Hello World message in the output screen as shown below.


Complete source code for this JAVA program is as shown below

package helloworld;
public class HelloWorld {
    public static void main(String[] args) {
                System.out.println("Hello World");
    }
   }

A short explanation of the above code is

 A JAVA program consists of Packages, A package combination of Classes and classes further composed of variables and methods and furthers define the executable statements.
First line of code is reference to the package which contains the class HellowWorld Class
package helloworld;

Seconds line of the code define the class
public class HelloWorld {
        }
Third line defines the method inside the class
public static void main(String[] args) {                
    }
Fourth line of the code is called executable portion called the statement. When computer execute this statement it show the output on screen 
                System.out.println("Hello World");
Output of this simple program is

Hello World