super() in Java

Mohan picture Mohan · Sep 22, 2010 · Viewed 503.1k times · Source

Is super() used to call the parent constructor? Please explain super().

Answer

pakore picture pakore · Sep 22, 2010

super() calls the parent constructor with no arguments.

It can be used also with arguments. I.e. super(argument1) and it will call the constructor that accepts 1 parameter of the type of argument1 (if exists).

Also it can be used to call methods from the parent. I.e. super.aMethod()

More info and tutorial here