This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why 1 public class  RSS feed

 
Arun Maalik
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi frnd i would like to know that why there is only one pubiic class in a java file if i will make more than one public class in a java file offcourse it will not compile but why?

with Regard

Arun kumar maalik
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arun Maalik:
Hi frnd i would like to know that why there is only one pubiic class in a java file if i will make more than one public class in a java file offcourse it will not compile but why?

with Regard

Arun kumar maalik


It's just for conventions.
Think if you have declared a class as public that means that you want to acces it from anywhere else also, now if you declare that class in some other Publicclass.java file. How do you find that, keeping into this mind These conventions are derived.

Hope it helps.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In other words, it just makes it possible to write a simpler, more efficient compiler.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!