1.4. Hello World Program
Open VS Code and create a new folder for your project.
Inside the folder, create a new file named
HelloWorld.java
.Add the following code to the file:
javapublic class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }
Save the file.
Open the terminal in VS Code (View > Terminal).
Compile the program by running:
bashjavac HelloWorld.java
Run the program by executing:
bashjava HelloWorld
You should see the output:
Hello, World!