For example, I have the following code (where I explicitly extend to
Object and call super()). My question is, what does the call do
super() do?
Actually, Object()
does nothing.
Now you should not reduce the constraint to invoke super()
(with args or not) for any subclass constructor to the case where you have a class that doesn't extend a class explicitly.
This case is the only one where invoking super()
may seem not really useful.
But as soon a class extends a class distinct from Object
, this constraint makes really sense as the child construction has to apply first its parent construction.
But the language specifies this point in a general way. It has no exception for classes that extend directly Object
.
Probably because, it makes things more simple and that is not a real constraint as the compiler adds for you the call to the super default constructor : super()
.