Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

More than one!!

 
Niyas Ahmed Sheikh
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic