Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java class names

 
yaswanth yash
Greenhorn
Posts: 12
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why a java file name and its class names should be same?
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because that's how the language was designed.

You'd have to ask the language designers for the real reason, but it's a sensible way of organising your code, and they decided to enforce one approach.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12122
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you search through this forum, you will find this has been asked and discussed many times.
 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yaswanth yash wrote:why a java file name and its class names should be same?

Why not? What would you suggest instead?

Winston
 
Naishadh Parmar
Ranch Hand
Posts: 95
C++ Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may ask this question to James Gosling, Mike Sheridan and Patrick Naughton this question(designers of this programming language) !!!
Its just a way of organizing and it is actually good so that there is no disconnect between the class name and the file name.
Or else if you wanted to know where an error occured you would have to open all the files see the class names and then identify the problem which would consume a lot of your quality time.
 
yaswanth yash
Greenhorn
Posts: 12
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope you can guess my suggestion...mr.winston
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yaswanth yash wrote:I hope you can guess my suggestion...mr.winston

No we can't. I can think of no better reasonable suggestion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic