捡历史的小木板

关注

kotlin 继承

捡历史的小木板

关注

阅读 78

2022-10-09


open class Student(var name: String, var age: Int) {
open fun say() {
println("name: $name, age: $age, say ------")
}
}

class G2Student(name: String, age: Int, var email : String) : Student(name, age) {

override fun say() {
println("name: $name, age: $age, email: $email, say ------")
}
}


fun main() {
val p =Student("adley", 18)
p.say()

val g2p = G2Student("孙晓辉", 20, "Beijing")
g2p.say()
}


相关推荐

phpworkerman

Android-kotlin的继承

phpworkerman 51 0 0

王远洋

Kotlin语法基础之继承

王远洋 114 0 0

Java架构领域

Kotlin教程 第7章 继承

Java架构领域 55 0 0

两岁时就很帅

12:kotlin类和对象 -- 继承

两岁时就很帅 57 0 0

快乐码农Alan007

android kotlin 基础复习 继承 inherit

快乐码农Alan007 19 0 0

穆风1818

Kotlin:为什么创建类不能被继承

穆风1818 14 0 0

小黑Neo

kotlin<第二篇>:类与继承

小黑Neo 51 0 0

西街小学的王

Kotlin 基本语法5 继承,接口,枚举,密封

西街小学的王 11 0 0

承蒙不弃

【Kotlin】Kotlin笔记3-面向对象编程1(类与对象,继承,构造函数)

承蒙不弃 153 0 0

棒锤_45f2

10天学会kotlin DAY6 继承、类、重载

棒锤_45f2 11 0 0

精彩评论(0)

0 0 举报