This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
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