In this tutorials, we are going to learn the basic Java Hello world example. Hello world Java program is the good starter program for all Java beginners.

Instead of directly going to dig into the hello world program, it is better to know the structure of the typical Java program since it is very important for all Java beginners like advantages of Java programming Language.

Structure Of  Java Class:

[java]

class <clsname> {
Variable declaration;
Method definition;
}

[/java]

Here, class is a keyword which is used for developing or creating user defined datatypes.

Clsname represents a JAVA valid variable name and it is treated as name of the class.

Class names are used for creating objects.

Class contains two parts namely variable declaration and method definitions.

Variable declaration represents what type of data members which we use as a part of the class.

Method definition represents the type of methods which we used as part of the class to perform an
operation.

Structure of Java Hello world Program :

[java]

class <clsname> {
    Data member’s declaration;
    User defined methods;
    public static void main(String k[]) {
        Block of statements ();
    }
}

[/java]

Java Hello world Example :

[java]

package com.onlinetutorialspoint.javaprograms;

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

[/java]

[tie_list type=”checklist”]

  • Every program in JAVA must be developed with respect to class.
  • Data member’s declaration represents the type of data members which we use as a part of the class.
  • User defined methods represents the type of methods which we use as a part of the class to perform some meaningful operation by making use of the data members of class.
  • Here main represents the name of the method where the program execution starts and void represent return type of main method which indicates main method does not return anything.
  • Since main method is executing only once hence it must be static method.
  • Since the main method can be called/accessed by everybody and hence it belongs to public method.
  • Block of statements represents the valid executable statements of JAVA which will call the
    user defined methods.

[/tie_list]

Happy Learning 🙂