File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes package scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package scope" Watch "package scope" New topic

package scope

Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
>>>A file can only contain one outer public class. If you attempt to create a file with more than one public class the compiler will complain with a specific error. A file can contain multiple non public classes, but bear in mind that this will produce separate .class output files for each class

I was reading above lines from link

did not understand it.If you have more than one class in a file say A, B, C, D classes out of which D is public and rest 3 ie A, B, C without any access modifier. Is that is legal. What it means about A, B, C classes as they have default scope now. Who all can see A, B, C
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 37913
Java™ Language Specification section about access. Look up default access, which many people call package-private
It is sorta covered in the JavaRanch Style Guide.
subject: package scope
Similar Threads
Public class in file
Public class
A question from MindQ
I need some help with this quiz!