aspose file tools*
The moose likes Beginning Java and the fly likes More than one!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "More than one!! " Watch "More than one!! " New topic
Author

More than one!!

Niyas Ahmed Sheikh
Ranch Hand

Joined: Jun 15, 2005
Posts: 129


Error Message:
AA111.java:1: class C is public, should be declared in a file named C.java
public interface C
^
AA111.java:6: class B is public, should be declared in a file named B.java
public interface B
^
2 errors

Why if I am using more than one 'public' class or interface raises an error?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

As the error messages imply, a public class X must be in a file named X.java. That's just the rule. You can include any number of nonpublic classes in a single file, however.


[Jess in Action][AskingGoodQuestions]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: More than one!!