Kotlin的主构造函数

主构造函数没有函数体,如果想在主构造函数中写一些逻辑,Kotlin提供了一个init结构体,所有主构造函数中的逻辑都可以写在里面: class Student(val sno: String, val grade: Int) : Person(){ init { println("sno is $s
posted @ 2024-02-21 21:24  touchmore  阅读(18)  评论(0编辑  收藏  举报