This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: why public for main
- From: Tom Tromey <tromey at redhat dot com>
- To: "amroz kamal siddiqui" <kamalamroz at rediffmail dot com>
- Cc: java at gcc dot gnu dot org
- Date: 05 Apr 2003 10:51:33 -0700
- Subject: Re: why public for main
- References: <20030405165307.30514.qmail@webmail24.rediffmail.com>
- Reply-to: tromey at redhat dot com
>>>>> ">" == amroz kamal siddiqui <kamalamroz at rediffmail dot 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