This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

query

 
Kartik Mahadevan
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose I have declared 2 classes as public in the same file then compilation does not take place ? Why?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

The simplest answer is because that's the rule: there can only be one public top-level class or interface per file.

If you need an explanation: it's just because it makes it easier for the compiler to find the source for a given class if it's in a file with the same name as the class.
 
Kartik Mahadevan
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank U very much
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic