Java Program Structure

Let's see below example to understand basic structure of Java program.

package BestJavaTutorial;
public class Simple
{
public static void main(String args[])
{
//Java Code
}
}

public static void

This creates a class called Simple.

Class names always start with a capital letter.

The word public means that class Simple is accessible by any other classes.

{…} Curly Brackets

The 2 curly brackets are used to group all the commands together so it is known that the commands belong to that class.

public static void main

The word public means that main method is accessible by any other classes.

The word static means that method is unique.

The word void means this main method never return any value.

The execution of the program start from main method.

You will notice that the main method code has been moved to some spaces left. This is called indentation which used to make a program easier to read and understand.

Previous Post Next Post

Contact Form