Structure of Java Program :-
Documentation Section
Package Declaration
The package declaration is optional. It is placed just after the documentation section. In this section, we declare the package name in which the class is placed.
Import Statements
The package contains the many predefined classes and interfaces. If we want to use any class of a particular package, we need to import that class.
Interface Section
It is an optional section. We can create an interface in this section if required.
Class Definition
In this section, we define the class. It is vital part of a Java program. Without the class, we cannot create any Java program.
Main Method Definition
In this section, we define the main() method. It is essential for all Java programs. Because the execution of all Java programs starts from the main() method. In other words, it is an entry point of the class. It must be inside the class. Inside the main method, we create objects and call the methods. We use the following statement to define the main() method:
0 Comments