In this tutorial, we are going to see the basic Java Hello world example. The Hello World program is a good starter program for all Java beginners.

Instead of directly dig into the hello world program, it is better to know the structure of some more basics of Java class.

Structure Of  Java Class:

Java Class
class <classname> {
  Variable declaration;
  Method definition;
}

Here, the class is a keyword, used to create user-defined data types, we generally call it a class.

The <Classname> represents a Java identifier, this represents the actual name of this class.

A typical Java class contains two parts, that are variable declaration and method definitions.

The variable declaration represents the properties of the class, which carries/holds the data. Java supports different types of data types like int, float, String and etc.

A Java method is a logic area where we define the behaviour of this class, a Java method may or may not return a value.

Structure of Java Hello world Program :

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

Java Hello World Example :

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

Output:

Console
 Hello World !

Happy Learning 🙂

About the Author:

Founder of onlinetutorialspoint.com Love Java, Python, Shell and opensource frameworks. Follow him on twitter and facebook for latest updates.

Leave A Comment