Thursday, February 18, 2010

JAVA BASIC SYNTAX

class Classname
{
  public static void main(String args[])
  {
   //Actual program
   Statements;
  }
}

1. public - Access Specifier, properties and methods can access anywhere, 
any package.
2. main() - The Java environment starts the execution of a program from 
main() method.
3. void - The main() method is not return anything. So the return type of 
the main() method must be void.
4. static - The jave environment able to call the main() method without creating 
an instance of the class. So its declared as static.
5.(String args[]) - In java, whatever we give, it will takes as String. So we are 
giving the command line argument as String.

There is one question that arises: Why do 
we use String args[] when we don't pass an  
argument.The answer for this is runtime 
always calls the method with String argument.

0 comments: