Skip to content

1.4. Hello World Program

  1. Open VS Code and create a new folder for your project.

  2. Inside the folder, create a new file named HelloWorld.java.

  3. Add the following code to the file:

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

  5. Open the terminal in VS Code (View > Terminal).

  6. Compile the program by running:

    bash
    javac HelloWorld.java
  7. Run the program by executing:

    bash
    java HelloWorld

You should see the output:

Hello, World!