Hello world basic program in java

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

In this program, we define a class named HelloWorld. Within the class, we have a main method, which serves as the entry point for the program. Inside the main method, we use the System.out.println statement to display the string “Hello, World!” on the console.

To run this program, you need to have Java installed on your computer. Save the code in a file named HelloWorld.java, open a terminal or command prompt, navigate to the directory where the file is saved, and then execute the following command:

javac HelloWorld.java

This command will compile the Java source code into bytecode. Once the compilation is successful, you can run the program using the following command:

java HelloWorld

You should see the output “Hello, World!” displayed on the console.

Leave a Comment