• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why only 1 public class is allowed in a single java file???  RSS feed

 
Vishu Shrma
Greenhorn
Posts: 5
Firefox Browser Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, ranchers, I am new to this forum, so questions can be a dumb-type also...

Can anyone tell me.....what is the reason behind of keeping only 1 class as "public" in a single java file. Also, we have to name that java file with the same class-name which was made public??
 
manish ghildiyal
Ranch Hand
Posts: 136
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Vishu,

I think better program organization and better readability are the major reasons which would had compelled java designers
to enforce this.Apart from that I don't see much into it. I think may be earlier programming languages like c++ allowed opposite to it
and caused many maintenance issues. So java went other way. After all java claims to be improved OO language compared to its
older cousins.

Manish
 
Vishu Shrma
Greenhorn
Posts: 5
Firefox Browser Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
manish ghildiyal wrote:
I think better program organization and better readability are the major reasons which would had compelled java designers
to enforce this.Apart from that I don't see much into it. I think may be earlier programming languages like c++ allowed opposite to it
and caused many maintenance issues. So java went other way. After all java claims to be improved OO language compared to its
older cousins.



Yeahh... I was also thinking something around it, thanks Manish for solving my doubt
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should also try searching this forum. This exact question has been asked and answered many times.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!