Java Program to Print Hello World

  • Java Program to print Hello world string on screen.
  • How to print a string in Java program.

In this java program, we have to print "Hello World" string on screen. Printing "Hello World" program is one of the simplest programs of Java programming languages. It become the traditional first program that many people write while learning a new programming language. It helps in understanding basic syntax of Java programming language and Java program structure to new programmers.

Java Program to print Hello World string on screen

In this java program, we are printing "Hello World" string using println method (System.out.println()). println method is used to print a line on screen.

package com.tcc.java.programs;

/**
 * Java Program to Print Hello World on Screen
 */
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}
Output
Hello World

Java Program to print Hello World string 10 times using for loop

In this java program, we will print "Hello World" string 10 times using a for loop. For loop will iterate 10 times and in every iteration it prints "Hello World" string once in a separate line using System.out.println method.

package com.tcc.java.programs;

/**
 * Java Program to Print "Hello World" 10 times using for loop
 */
public class HelloWorldLoop {
    public static void main(String[] args) {
        int i;
        for (i = 0; i < 10; i++) {
            System.out.println("Hello World");
        }
    }
}
Output
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World