Tuesday, October 30, 2018

class - java: Why must I write super() in the first line of the constructor



Possible Duplicate:
Why does this() and super() have to be the first statement in a constructor?






I just learned that at school, but the teacher doesn't know why.



I can think of some good reasons, but I think there are cases when the initializing can be done later in the constructor- before you use the variables form the mother class, for example. OK, the variables should be initialized from the start, but that's not always necessary.



I"m guessing there are a more reasons for that why must super() be placed in the first line of the constructor.




So, why must I write super() in the first line of the constructor, when I'm inheriting a class?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...