https://www.gcreddy.com/2021/05/java-program-structure.html
Java Program Hierarchy:
Java Project
Java Package
Java Class
Java Program Structure, Java Environment setup, Java Syntax, Java Language Fundamentals, Writing Java statements, and writing Java code blocks.

Java Program Structure – Java for Selenium
Sections of Java Program
1. Documentation Section – Optional

2. Package Statement – Mandatory

3. Import Statement/s – Depends on our program requirement

4. Interface Section //Optional

5. Class Definition { //Mandatory

6. main method(){
//Main Program contains normal statements and code blocks

Object Creation //Depends on our program requirement

Declarations/Initialization/Reading – normal statements

Operations, Display statements, etc…

Code Blocks, Conditions/Decision-making blocks, Loop Blocks, Constructor Block., Etc…
}

}

1. Documentation Section

It includes comments to tell the program’s purpose, it improves the readability of the Program

2. Package Statement

The package statement identifies the package that a Java program belongs to. If your program does not include a package statement, the program belongs to the default package, which is simply a package that has no name.

Example: package abcd;

3. Import statement/s

We import predefined and user-defined libraries using the “import” keyword

Example:

import java.util.Scanner;
java – Project
util – Package
Scanner – Class

import java.util.*; // Importing all classes from a package

4. Interface Section

It is an optional section. We can create an interface in this section if required. We use the interface keyword to create an interface. An interface is slightly different from the class. It contains only constants and method declarations.

5. Class Definition

Ex:
public class Sample{

}

6. main() Method

Java program execution starts from the main() method, which is mandatory in every Java program.

public static void main (String [] args){
//Code
}

public – Access Modifier
static – Non Access Modifier (use the main method without invoking an object)
void – Returns Nothing
main – Predefined Identifier(Method name)
——————————————-
//Within the Main method

main method{
//Main Program
Creating Object/s
ClassName objectName = new ClassName();

Comments
Declarations….(Variable with Data Types, Constants/Final Variables)
Normal Statements
int a;//Declaration
a=100;//Initialization
int b=a;//Reading
System.out.println(10+20); //Print Statement
final int x=100;

if (){ //Condition Code Block
.
}

for (){ //Loop Code Block
.
}

}

Java Syntax and Program Structure