Java main method
By writing4angels, 26th Nov 2010 | Follow this author
| RSS Feed | Short URL http://nut.bz/qz249obn/
Posted in WikinutGuidesTechnologyComputer Software
For the basic programmers in java as well as for the interviews having the knowledge about the structure of main method is a must.
Java main method
Let us have a look at simple java program that will give an output of a sentence:
First java program.
Class FirstProgram
{
public static void main(String args)
{
System.out.println(”First java program”);
}
}
As shown in the above example the name of the java class is FirstProgram and there is java main method that has the print statement to give the output on command line.
Java main method as shown here is:
Public: Can be accessed outside the class and package.
Static: Can be accessed by the interpreter without creating object and there is only one reference to point to main method.
Void: Returns no datatype.
Argument: Java main method accepts arguments from command line called command line arguments in the form of array.
Java main method is the starting point of your application and triggers the execution of your program.

Comments