As far as i know Main method should always be declared as Public. JVM needs to find and invoke this method. Have you ever tried running your main method without Public keyword ? [ August 28, 2007: Message edited by: Chandra Sekar ]
SCJP 1.4, SCWCD - Preparing
A pessimist sees difficulty in every oppurtunity, An optimist sees oppurtunity in every difficulty.
Originally posted by Jose Campana: ...in some IDEs when you don't provide the public access modifier, it doesn't allow you to declare the main method...
Hmmm... I don't like that at all. I often write main methods into classes for testing, even if they're not going to be the program's entry point.
In general, a top-level class that's declared public is available everywhere, even outside of its own package. A top-level class with no access modifier has default access, which is restricted to within its own package. (If no package is declared, then it is part of an "unnamed" package, which usually means the current directory.)
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Joined: May 28, 2007
Hello Fellow Ranchers !
Thanks, that claryfied it all!....So a class declared with the public access modifier determines how classes outside the class' package are able to access it...(in this case any class outside can, right)
Yeah, to me it is also disturbing that NetBeans 6.0(Preview) doesn't allow me to declare a if the class doesn't have the public access modifier. It's a pity because I use classes with a main method for testing as well.
Well, thank you very Guys ! Keep up the awesome Work !