The usually structure of a basic java program is:
Documentation Section - You can write a comment in this section. Comments are beneficial for the programmer because they help them understand the code.
Package Statement - You can create a package with any name. A package is a group of classes that are defined by a name (only required if you are using packages).
Import Statements - This line indicates that if you want to use a class of another package, then you can do this by importing it directly into your program.
Interface Statement - Interfaces are like a class that includes a group of method declarations (optionally).
Class Definition - A Java program may contain several class definitions. Classes are the main and essential elements of any Java program.
Main Method Class - Every Java stand-alone program requires the main method as the starting point of the program. This is an essential part of a Java program. There may be many classes in a Java program, and only one class defines the main method. Methods contain data type declaration and executable statements.
//Name of this file will be "Test4.java"
public class Test4 {
/* Author: Hameed
Date: 28/10/2019
Description:
Writes the words "Hello World" on the screen */
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
java -version
– Karthikeyan Vaithilingam