This week's book giveaway is in the Android forum.
We're giving away four copies of Create an Uber Clone in 7 Days: Build a real world full stack mobile app in Java and have Shai Almog on-line!
See this thread for details.
Win a copy of Create an Uber Clone in 7 Days: Build a real world full stack mobile app in Java this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

super()  RSS feed

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why super() is always first statement inside any local context
 
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not necessarily if you have overloaded constructors.
If its not super(), what else you can have? Can you think of a class that is not an Object?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The rules of the Java language say that the parent class's constructor must complete before the child's constructor executes. The is enforced by requiring that the first statement in every constructor (except Object's) is a call to either a parent's constructor or to another constructor in the current class (which will eventually lead to a current class c'tor that invokes a parent c'tor).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!