Java Program Structure
Java Program Structure
o Documentation Section
o Package Declaration
o Import Statements
o Interface Section
o Class Definition
o Main Method Class
Documentation Section:
Package Declaration
The package declaration is optional.
It is placed just after the documentation section
This statement declares a package name and informs the compiler that the classes
defined here belong to this package.
Import Statements:
If we want to use any class of a particular package, we need to import that class.
We use the import keyword to import the class.
We use the import statement in two ways, either import a specific class or import all
classes of a particular package.
Ex:
interface car
{
void start();
void stop();
}
Class Definition:
EX:
Example: