• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why public class should be stored in same filename as of class?

 
Nancy Antony
Ranch Hand
Posts: 145
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I'd like to know why .java file should have same name as of public class ?

Nancy
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at this post. It's your java platform that decides whether this is enforced or not.

Regards, Jan
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Imagine the nightmare of trying to find a class' source file if you could name it anything you wanted... (without using an IDE that is.) Some one could save the "AccountInformation" class in a file named "FileSystemDeleteMechanism.java". And believe me, there are people that would do such crazy things if Java didn't prevent it. To me, it just one of those common sense rules they put into Java. And I for one am glad it is there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic