Java main() method
Java main() method
Like C,C++ and other programming language Java has also a main method.
The program's execution starts from the main method.
The java's main method is :
public static void main(String args[])
{
//statements
}
Expanation of the method :
public :
It is an access specifiers. It means that this method can be called by any object.
We will discuss the access specifiers in more detail.
static :
It means that we don't need to create an object to call this method.
Static is a keyword that indicates that it is a class method which can be called without creating the object.
void :
It is a keyword that tells that the method doen't return anything.
main :
It is the name of the method.
args :
It is the formal parameter. It is an array of type String.
We will discuss about arrays and String data type in more detail.
Example :
public static void main(String args[])
{
int a;
int b;
int sum=0;
sum=a+b;
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment