kotlin中方法默认是final的,不可被子类重载,若需要被重载,使用关键字open进行修饰,子类重载方法使用override关键字:
open class Obj{
open fun study(){}
fun run(){} //不可被重载
}
class Student:Obj{
override fun study(){}
}
kotlin中方法默认是final的,不可被子类重载,若需要被重载,使用关键字open进行修饰,子类重载方法使用override关键字:
open class Obj{
open fun study(){}
fun run(){} //不可被重载
}
class Student:Obj{
override fun study(){}
}