Every Java program starts from a class and a main method. The first program below prints a message on the screen.
class HelloWorlddeclares a class named HelloWorld.public static void main(String args[])is where the program starts running.System.out.println("Hello World");prints the text and moves to a new line.
Save the file as HelloWorld.java, compile it with javac HelloWorld.java and run it with java HelloWorld.
Unit - 1 HelloWorld Example - Source code
import java.*;
class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello World");
}
}
Unit - 1 HelloWorld Output:

