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

public class in a file question .

 
Sahil Reddy
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Pals

I have read that

" The name of a file should be same as that of the public class in a file, if any "

I just want to know why ???


Thanks
 
Rob Spoor
Sheriff
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please SearchFirst. This question has been asked many, many times before.
 
Sahil Reddy
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think almost every question have been answered , if one has to search for everything then it is not more a forum, it would be like google search.
After all , my same question would give some newcomer to answer it and enforces his/her learning. This is what a benefit of forum is at the first place.

Regards
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, for such questions Google search (or a forum search) is far more efficient than posting to a forum. You'll find an answer much quicker that way.

It's not a very helpful question to give a newcomer anyway, because the answer is simply "the designers of the language decided to do it that way". They could have decided to make it work another way, but they didn't. it has the advantage that for any given public class, it's very easy to identify which file it's in.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic