• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question re: Identifiers

 
Mike Kelly
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can a normal method be named the same as the class, and if so how can we tell it from a constructor?
 
frank davis
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A method must have a return type, a constructor does not.
 
Junilu Lacar
Bartender
Posts: 7480
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, if you really want to confuse users of the class
A normal method must have a return type (even if it is just void) while constructors can not have a return type.


[This message has been edited by JUNILU LACAR (edited July 23, 2001).]
 
Mike Kelly
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by herb slocomb:
A method must have a return type, a constructor does not.

Thanks, got it.
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike, just donot think about it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic