Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

same class n method name

 
usha prithvi
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Though itz not a compiler error, for the class and the method to have the same name, y is it not preferred?(the editor says"method has a constructor name") can someone explain me this?

Thankz
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Constructor is a method that has the same name as the class name. So if you are having a method with same name as the class name but with a return type, it decreases the clarity of the code and leads to confusion so it's better to avoid that.
 
usha prithvi
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Itz more clear to me now.Thankz for the explanation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic