wood burning stoves*
The moose likes Beginning Java and the fly likes Source file and public class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Source file and public class" Watch "Source file and public class" New topic
Author

Source file and public class

Jiaqi Lin
Greenhorn

Joined: Jul 20, 2007
Posts: 2
Hi, while doing the Java Rule Round-Up, I came across a question that says each source file need not have a public class. Can someone provide some examples, cos I am not really sure of what the question is asking.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

You can specify a "public" access modifier for a top-level class, which makes it accessible everywhere. If you don't specify an access modifier for a top-level class, then it has default access (restricted to the package). So the following could be a source file that does not contain a public class...


"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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Source file and public class