Java

Hello World Java Program Example

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 :)

Found a mistake or something out of date? Tell us →

Written by

chandrashekhar

Founder of onlinetutorialspoint.com. Enterprise architect with 15+ years in healthcare technology, designing and running systems on AWS and Azure. Writes about building real things with AI, local AI hardware and cloud certifications.

Keep reading

Ask a question or leave a comment