当前位置:网站首页>Kotlin inheritance
Kotlin inheritance
2022-07-04 19:42:00 【AdleyTales】
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(" Sun Xiaohui ", 20, "Beijing")
g2p.say()
}
边栏推荐
- An example of multi module collaboration based on NCF
- @transactional滥用导致数据源连接池耗尽问题
- abc229 总结(区间最长连续字符 图的联通分量计数)
- socket编程demo二
- 1007 maximum subsequence sum (25 points) (PAT class a)
- Personal thoughts on Architecture Design (this article will be revised and updated continuously later)
- Upgrade the smart switch, how much is the difference between the "zero fire version" and "single fire" wiring methods?
- Shell 编程核心技术《三》
- How to use async Awati asynchronous task processing instead of backgroundworker?
- "Only one trip", active recommendation and exploration of community installation and maintenance tasks
猜你喜欢
随机推荐
1008 Elevator(20 分)(PAT甲级)
C# 使用StopWatch测量程序运行时间
《工作、消费主义和新穷人》的微信读书笔记
HDU 1097 A hard puzzle
项目中遇到的线上数据迁移方案1---总体思路整理和技术梳理
黑马程序员-软件测试--07阶段2-linux和数据库-09-24-linux命令学习步骤,通配符,绝对路径,相对路径,文件和目录常用命令,文件内容相关操作,查看日志文件,ping命令使用,
Shell programming core technology "three"
HDU 1372 & POJ 2243 Knight moves (breadth first search)
1011 World Cup Betting (20 分)(PAT甲级)
线上数据库迁移的几种方法
Several methods of online database migration
如何使用Async-Awati异步任务处理代替BackgroundWorker?
The kth largest element in the array
牛客小白月赛7 谁是神箭手
1011 World Cup betting (20 points) (pat a)
【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案
kotlin 继承
abc229 总结(区间最长连续字符 图的联通分量计数)
联想首次详解绿色智城数字孪生平台 破解城市双碳升级难点
Functional interface