static:
we declare a method in a class "static" when we decide
that to be part of just that class. we do not want that method to be
part of objects. the keyword static helps the Java VM to start the
main method without creating instance of the class in which main is
declared. Actually static methods or fields can be called by any other
part of the program without creating the instance of the class. Java
VM Interprester uses this property.
For example System.out.println() is a static method and we can call
it from anywhere we want without instantiating.
we need to keep another point in mind that Java can
execute a class without instantiating as long as its static methods do
not call any non static method or fields.
void:
it is the Java VM who calls the main method. It does not
expect any return parameters. So the type is void. main is not
returning any value to its caller.
args:
its an optional tool of a Java Program. args adds a feature
for Java Program. If someone wants to pass on runtime arguements to
the program, args helps to pass such arguements. it could be a single
or array of strings. if we do not want to pass any arguements, it
stays without any use.
Wed, Jan 21, 2009 at 9:12 AM, Srini S <[email protected]> wrote:
>
> Hi,
>
> I understant that main method is called first. However, can someone
> explain me the details of using this syntax:
> public static void main (String[] args)
> I understand "public" and "main" is the method but doesn't understand
> static, void, and args. Any help appreciated.
>
> Thanks,
> Srini.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---