Java Hello World Program | Print Hello world in Java Example

Above we have discussed Java Hello World program tutorial for how to write Hello World in Java. Hello World is a simple and very popular program....

Hey guys, welcome to this interactive tutorial on the Java programming language. 

In this article, you will learn how to write Hello World in Java. Hello World is a simple and very popular program which is done by newbie before starting any programming language. So let's learn how to print Hello World in Java, but before that let's take an overview of the Java programming language.

Java Hello World Program | Print Hello world in Java Example

What is Java ?

Java programming language is a multi purpose, object oriented, high level programming language which is designed in the year 1991 by Patrick Naughton, James Gosling and Mike Sheridan. And the first version of Java programming language was released by James Gosling in the year 1995. Java programming language is a simple and powerful programming language which provides the feature of Automatic garbage collector. Java programming language is a platform independent programming language which means programmers can run java on different operating systems like Windows, Linux, Unix, macOS, FreeBSD, OpenBSD, Solaris, etc.

Requirements for printing "Hello World" program in Java

• Good Configuration Computer.

Java JDK Should be installed.

• IDE or Source code Editor (such as VS code, eclipse, IntelliJ Idea etc.)

Print "Hello World" program in Java

Now, let's start our first program i.e., Print Java Hello World program. For that just copy this following code;

// Your First Program 

class HelloWorld { 

public static void main(String[] args) { 

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

}

 }
The Output should be read; 

Hello World!!

If you see such output then congrats you have executed your first program in java programming language. 

Now, let's know how this Hello World program works;

How Java Hello World Program works

Here, we will briefly discuss the different parts of Hello World Program;

1. // Your first program

Any line which has // in its starting is a comment in Java programming language and the java compiler totally ignores it. Comments are used to make users understand the intention and program's functionality.

2. Class HelloWorld {....}

Every application has to be started with a class definition in Java programming language and the name of class should be similar to the name file in Java. Here, the name of class is class definition is as follows;

class HelloWorld {

... .. ...

}

3. Public static void main {....}

This is defined as the main method and in Java programming language, it is mandatory to include the main method as the compiler starts execution from the main method. And the main method is written as follows:

public static void main(String[] args) {

......

}

4. System.out.printin("Hello World!!")

This is a print statement. This statement prints out the text in your screen. In Java programming language, the text written inside the quotation marks is known as String.

Notes

- To make java program valid, class is mandatory.

- You have to write the method inside the class definition.

Format of Java program

The programs written in Java programming language are quite long and single program may take multiple lines. But you just remember the following format as each java program will have similar format like this;

// Your First Program 

class HelloWorld { 

public static void main(String[] args) { 

// Write your code 

}

 }

Conclusion

Above we have discussed Java Hello World program tutorial for how to write Hello World in Java. Hello World is a simple and very popular program which is done by newbie before starting any programming language. By following above mentioned steps you can easily execute Hello World program in java programming language. And I hope this information is helpful to you.