Java Program to Print Hello World

Write a Simple Java Program to Print a Hello World message with an example. It is a simple, basic, and traditional program to start the Java programming language. It also helps you to understand the basic programming structure of Java.

This Hello World program example uses the standard println function to print the message.

public class HelloWorld {

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

}
Simple Java Program to Print Hello World 1

The System.out.println statement prints the statement inside the double Quotes. So, the statement inside the main prints the message Hello World.

Java Program to Print Hello World Multiple Times

In this, we are using Java For Loop to print the same statement multiple times. You can also use While Loop or Do While to get the same result. To understand this program, Please refer to the For Loop, While Loop, and Do While articles.

public class Example {

	public static void main(String[] args)
	{
		int i;
		for(i = 0; i < 3; i++)
		{
			System.out.println("\n Hello World ");
		}	
	}
}
Java Program to Print Hello World multiple times using for loop

Comments are closed.