How to write a Hello World in Java?

To write a “Hello, World!” program in Java, you can follow these steps:

  1. Open a text editor or an integrated development environment (IDE) like Eclipse, NetBeans or IntelliJ IDEA.
  2. Create a new Java file and give it a meaningful name. For example, you could name it
  3. In the file, type the following code:
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");

4. Save the file.

This program defines a class called HelloWorld with a main method that prints the message “Hello, World!” to the console using the System.out.println method. When you run this program, the message will be displayed in the console. To run the program, you can use the Java Development Kit (JDK) and execute the command java HelloWorld in the terminal or command prompt.


Hello, World!

Sharing Is Caring