File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please HELP...HELP

 
Rahul Gupta
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Monty Ireland
Ranch Hand
Posts: 161
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Dave Vick
Ranch Hand
Posts: 3244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic