Tuesday, September 30, 2008

Java - main() method - in shot

Let us think about

public static void main(String args[]){
}

here,
public - specified for java interpreter to access the class
from out side of the class.
static - we need to call main() method before the object creation
of that class.
instance methods can be called after instantiating the class
and by using object reference variable.
void - main() method which return nothing to caller JVM
args[] - this is a String array ,which is used for giving inputs
to our program while running is
eg: java SampleClass Kalathuru Thanooj JavaTemple
for( int i=0; i
System.out.println(args[i]);
}

Note: we can also override the main() method.

No comments: