why public for main
Tom Tromey
tromey@redhat.com
Sun Apr 6 08:10:00 GMT 2003
>>>>> ">" == amroz kamal siddiqui <kamalamroz@rediffmail.com> writes:
>> Iam a newbie in java, I just have a simple and a very
>> annoying ( at least to me ) question. Why do we use the keyword
>> public for the main method ?
>> eg.
>> public static void main(String arg[])
It is conventional, that's all.
>> but the following does not work,
>> void main(String arg[])
In this case main is an instance method, meaning it requires an object
reference to call. Java will only call a static main method. I don't
know the rationale here; maybe just for simplicity's sake.
Tom
More information about the Java
mailing list