Two Laptop Bag*
The moose likes Beginning Java and the fly likes main Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "main" Watch "main" New topic
Author

main

michael aron
Greenhorn

Joined: Jan 30, 2001
Posts: 5
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

Joined: Jan 26, 2001
Posts: 439
It's a known bug , it's been documented by Sun


Val SCJP <BR>going for SCJD
ankush walia
Ranch Hand

Joined: Jan 24, 2001
Posts: 95
AND I THINK THIS BUG HAS BEEN REMOVED IN jdk1.3 PACKAGE!!
ankush!!
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
Nope still have it , i use jdk1.3 it's there
venkatesan Rajagopalan
Greenhorn

Joined: Jan 12, 2001
Posts: 15
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

Joined: Sep 29, 2000
Posts: 8521
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()


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: main