java
  1. java

Java Hello World Program

Syntax

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Example

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Output

The output of the above Java program would be:

Hello, World!

Explanation

Java Hello World program is the most basic program that one can write in any programming language. In this program, we create a class named HelloWorld with a main method which is the entry point of any Java program. Inside the main method, we print the string "Hello, World!" to the standard output using the System.out.println() method.

Use

The Java Hello World program is used to introduce beginners to the Java programming language. It helps them understand the basic syntax and structure of a Java program. It is also used as a starting point for more complex Java programs.

Important Points

  • The class name and the file name should be the same
  • The main method should be declared as public static void
  • The System.out.println() method is used to print output to the console
  • Java is case-sensitive, so System.out.println() is not the same as system.out.println()

Summary

Java Hello World program is the most basic program in Java that prints the string "Hello, World!" to the console. It is used to introduce beginners to the Java programming language and is a starting point for more complex Java programs.

Published on:
Java Arrays
Java Strings and Regex
Exception Handling in Java
Java Inner Classes
Java Multithreading
Java I/O (Input/Output)
Java Networking
Java Reflection
Java Date and Time
Java Conversion
Java Collections
Java Database Connectivity (JDBC)