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 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 Java program, Please refer to the Java For Loop, Java While Loop, and Java Do While loop articles.

public class Example {

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

Also Read

Comments are closed.