This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: why public for main


>>>>> ">" == 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]