This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Constructor" Watch "Constructor" New topic
Author

Constructor

shiva shankar
Ranch Hand

Joined: Jun 10, 2001
Posts: 84
Hi all,
When I am calling a constructor within a constructor, why is it that I need to call using this(). Why can't I use the same name as that of class when I am overloading the constructor.
Regds
Shiva
Donald R. Cossitt
buckaroo
Ranch Hand

Joined: Jan 31, 2003
Posts: 401
My guess is that to use MyClass( name ) is trying to say we want a 'new' object not use a constructor. While the keyword this() is saying a constructor of 'this' class.

Is this clear as mud?


doco
John Lee
Ranch Hand

Joined: Aug 05, 2001
Posts: 2545
hi:
please refer to:
http://java.sun.com/j2se/1.3/docs/api/java/lang/reflect/Constructor.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Constructor
 
Similar Threads
Constructor's in Interface. Why not ?
Flow of the program in Constructors
Constructors in EJBs
Why Oject class constructor is called?
abstract class constructor