jQuery in Action, 2nd edition*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 24183
    
  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]
 
Don't get me started about those stupid light bulbs.
 
subject: More than one!!
 
Similar Threads
public modifier
Interface
Major problem with GuessGame code, ch02 of "Head First Java, 2nd edition, covers Java 5.0"
interface error
Public Interface Problem