File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Constructors

 
Tarun Oohri
Ranch Hand
Posts: 189
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 989
9
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 189
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic