Java is an object oriented programming language. Every Java program start with a class definition. The file name of Java should be same as the class name. The following program prints “Hello world”.
package com.company;
public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Output:
Hello World
The public static void main is the main method and should be present in all Java programs. Program execution starts from the main method. The statement System.out.println() has a println() method which prints “Hello World” on the screen.