aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes access modifiers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "access modifiers" Watch "access modifiers" New topic
Author

access modifiers

Peter Warde
Ranch Hand

Joined: Aug 18, 2004
Posts: 71
class MyClass {

public static void main( String [] args ) {
// some code
}

}

My understanding here is that the class has default access ie cannot be seen outside it's package, and that the class visibility has priority over any method visibility that are wider. How then is it possibile to access the public main method with java MyClass 123 command line argument ( which it is ) when the class is default?

Peter
Fletcher Estes
Ranch Hand

Joined: Jul 01, 2004
Posts: 108
Access control applies between classes themselves, rather than between the JVM and classes. When you launch the JVM using the 'java' command, the same rules do not apply - all it needs to find a class and run its main method is the location on disk. This is a special relationship between the JVM and a class's main method, which is only recognised by the signature public static void main(String[] args)
 
jQuery in Action, 2nd edition
 
subject: access modifiers