Kotlin’s super keyword reaches an inherited implementation or initializes a superclass constructor. It is especially useful when a class inherits conflicting default methods or exposes several construction paths. section 4.1.1 section 4.2.2
Selecting an inherited interface implementation
When Clickable and Focusable both define showOff(), Button must override it explicitly. The override can invoke both implementations: class Button : Clickable, Focusable { override fun click() = println("I was clicked") override fun showOff() { super<Clickable>.showOff() super<Focusable>.showOff() } } The angle-bracketed type identifies which inherited implementation to call. If only one implementation is needed, an expression body is enough: override fun showOff() = super<Clickable>.showOff(). section 4.1.1
Use super in two closely related Kotlin situations:
- Call a specific inherited interface method with super<Type>.method(). Kotlin requires an explicit override when multiple supertypes provide the same default method. section 4.1.1
- Delegate a secondary constructor to a matching superclass constructor with : super(arguments). Each secondary constructor must either initialize the base class or delegate to another constructor that does. section 4.2.2
- Delegate between constructors of the same class with : this(arguments), then let the delegated constructor call super(). section 4.2.2
Listing 4.5 Invoking an inherited interface method implementation
class Button : Clickable, Focusable {
override fun click() = println("I was clicked")
override fun showOff() { #1
super<Clickable>.showOff() #2
super<Focusable>.showOff() #2
}
}
Inspect the complete Button example showing qualified super calls for both inherited interface implementations. section 4.1.1
class MyDownloader : Downloader {
constructor(url: String?) : super(url) { #1
// ...
}
constructor(uri: URI?) : super(uri) { #1
// ...
}
}
Inspect the MyDownloader example showing two secondary constructors invoking different superclass constructors. section 4.2.2
The syntax differs from Java for interface defaults: Kotlin uses super<Type>.showOff(), whereas Java uses Clickable.super.showOff(). Kotlin’s secondary-constructor delegation follows the same inheritance-oriented purpose while preserving Java-oriented constructor shapes. section 4.1.1 section 4.2.2





