open class Base {
open fun v() {}
fun nv() {}
}
class Derived() : Base() {
override fun v() {}
}
This is an example. Can someone please
By default, the functions in Kotlin are defined as final
.
That means you cannot override them. If you remove the open
from your function v()
than you will get an error in your class Derived
that the function v
is final and cannot be overridden.
When you mark a function with open
, it is not longer final
and you can override it in derived classes.