This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

which one to use first between this and super?

 
Sonu Nigam
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if in a subclass we want superclass constructor to be accessed and i want to use both this and super keyword and both are written just after the constructor defined then in above case which one will be written first?
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't call both a super- and this-constructor in one constructor. It's simply not allowed.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can only use one of the two. If you use "this", then another constructor will be called in the same class; if that constructor uses "this", then a third constructor will be called, etc. Eventually, you'll get to a constructor that doesn't use "this", and in that constructor, "super" can appear.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic