📜  kotlin 接口 - Kotlin 代码示例

📅  最后修改于: 2022-03-11 14:53:32.485000             🧑  作者: Mango

代码示例1
fun main() {
    Child().hairColour() /// brown
    Child().eyeColour() /// blue
}


interface Parent {
    val eyeColour: String
        get() = "blue"
    val hairColour: String
        get() = "black"

    fun eyeColour() {
        println(eyeColour)
    }

    fun hairColour() {
        println(hairColour)
    }
}


class Child : Parent {
    override val hairColour = "brown" 

}