Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

main

 
michael aron
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I always read that the main method must be defined as public static void... however I am able to compile and run programs with this method defined at any visibility level such as private. I am also able to declare my main method as final. Why is this the case, is it my JVM? What are the advantages and disadvantages of changing these?
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a known bug , it's been documented by Sun
 
ankush walia
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AND I THINK THIS BUG HAS BEEN REMOVED IN jdk1.3 PACKAGE!!
ankush!!
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope still have it , i use jdk1.3 it's there
 
venkatesan Rajagopalan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes it is true. By convention the main method should be public static in that order. as far as exam is concerned we should stick to the fact that the main method should be public static void main(String args[]){}
Correct me, if I am wrong.
regards
venkat
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you are correct. Even though Sun has an "undocumented feature" that recognizes main() without the public, NEVER respond to an exam question with anything other than
public static void main()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic