Get your CodeRanch badge!*
The moose likes Java in General and the fly likes CONSTRUCTORS WITH DIFFERENT NAME FROM ITS CLASS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "CONSTRUCTORS WITH DIFFERENT NAME FROM ITS CLASS" Watch "CONSTRUCTORS WITH DIFFERENT NAME FROM ITS CLASS" New topic
Author

CONSTRUCTORS WITH DIFFERENT NAME FROM ITS CLASS

Richard Teston
Ranch Hand

Joined: Feb 12, 2002
Posts: 89
Can constructors can have a different name from it's class?
Just wondering....


The Code is the Programmer
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

No they can't.
Richard, please review JavaRanch's naming policy and change your name in your profile to an acceptable format (FirstName LastName).
Thanks,


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Just to throw in something here....constructors are not inherited either, nor can they return a value, although you can have a method with the same name as a constructor and with a return value, which looks like a constructor but is not. Sneaky little bug that one!


Rob
SCJP 1.4
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Originally posted by Rob Ross:
Just to throw in something here....constructors are not inherited either, nor can they return a value, although you can have a method with the same name as a constructor and with a return value, which looks like a constructor but is not. Sneaky little bug that one!


Thank you for that tidbit, Rob. That's a good one to tuck away for exam day, etc.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
Don't get me started about those stupid light bulbs.
 
subject: CONSTRUCTORS WITH DIFFERENT NAME FROM ITS CLASS
 
Similar Threads
Questions for you
Diffrence b/w constructor and method Breiefly
Constructor
differnce between constructor and method
private constructors