• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Please HELP...HELP

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic