aspose file tools
The moose likes Beginning Java and the fly likes public class in a file question . Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "public class in a file question ." Watch "public class in a file question ." New topic
Author

public class in a file question .

Sahil Reddy
Ranch Hand

Joined: Jan 24, 2011
Posts: 143
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

Joined: Oct 27, 2005
Posts: 19216

Please SearchFirst. This question has been asked many, many times before.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Sahil Reddy
Ranch Hand

Joined: Jan 24, 2011
Posts: 143
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

Joined: Apr 06, 2010
Posts: 3795
    
    1

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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: public class in a file question .
 
Similar Threads
URGENT
Code problem or logic problem ?
Query -> inheritance
Two public classes in a file
Why one public class