This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Please HELP...HELP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Please HELP...HELP" Watch "Please HELP...HELP" New topic
Author

Please HELP...HELP

Rahul Gupta
Ranch Hand

Joined: Nov 20, 2002
Posts: 37
Hi,I had seen in many sites and certification books that the access specifier public in the main methods signature
public final static void main(String args[])
{ /*...*/}
is mandatory.
However I find that even with other access specifier with main (other than public like protected, private etc.) the code compiles and runs fine.
Please specify what exactly is mandatory and what is not. I am confused.
Thanks,
Rahul


regards,<p>rahul <p>SCJP 1.4<br />--------<br />Life is great, make it meaningful<br />---------------------------------
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
public static void main()
or combinations of the above are a requirement for the sun certifcation programmers exam.
depending on what you ar doing. other access modifiers will work. my i recommend an hour or so of reading about access modifiers.
after you have spend on hour reading...
please come on back...
we are all here to help on and other


Multi Platform Database Developer & DBA on E.S.T.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Rahul
Like Monty said the spec says that the method will be written as public static void main so if you are asking this question in the context of taking the exam then the only correct answer is the way written above.
However, there is/was a bug in pre 1.4 version of the language that allowed compilation of the main method with different access levels. This has been fixed in 1.4 so it is no longer an issue.


Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please HELP...HELP