Structure of Java

Java Structure

The structure of a program is an important aspect of the overall design of the Application.

The Java program structure is divided into various sections, namely

Package statement:

It is the first statement in java program that tells the compiler that all the classes defined in the file belong to this package.
For example, consider this statement.package employee;
Here, employee is the name of the package. It is not neccessary that our classes are part of package, so this statement is optional

Import statement:

Import Statements: allows us to access a class which belongs to some other package.
For example, consider this statement.import employee.EName;

Interface statements:

Interface Statements : An interface is the way for implementing multiple inheritance in Java. It is just like a class but it contains only method decrlarations.

Class definitions:

Class definitions: Class is the most important element of a program. A program may consists of any number of class definitions

Main method class:

It is an essential part of a Java program as it containsthe main method whichis the starting point of aprogram. Inside the main method class, the objects of several classes can be created, accessed and manipulated.
Once all the instructions in the main method are executed, the control is transferred out of the class thus terminating the entire program.



  Welcome to aimtocode:
  This My first program

In our First Java program, on the first line we have written a comment statement. This is amulti-line comment. Then actual program starts with class Myprogram

here, class is keyword and MyProgram is a variale name of the class, The class definition shuld be within the curly brackets. Then comes public static void main(String args[])

This line is for function void main(). The main is of type public static void. Public is a access mode of the main() by which the class visibility can be defined. Typically main must be declared as public.