This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Constructors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Constructors" Watch "Constructors" New topic
Author

Constructors

Tarun Oohri
Ranch Hand

Joined: Feb 20, 2013
Posts: 172
Hello Everyone!!!
I have read somewhere that the constructor's first statement is either "super" or "this" . We can not use both of them together. But i implemented this concept.. it turned out to be completely wrong.
Look at the following code :


It is printing 1,2,3 but it should not go to its super class !!! because first line of the constructor is "this"!!!
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 888
    
    9
What you are forgetting is that the constructor you are calling with "this" also has a call to super that is inserted there for you.
Tarun Oohri
Ranch Hand

Joined: Feb 20, 2013
Posts: 172
E Armitage wrote:What you are forgetting is that the constructor you are calling with "this" also has a call to super that is inserted there for you.


oh yes you are right.. silly me
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Constructors
 
Similar Threads
super().this()!
Constructor
choose between 2 run methods
Polymorphism Question
Constructors are not inhertied - True