//写法一:
class Student(name: String, age: Int) : Person2(name, age) {
}
//写法二:这样写下所有的,attrs: AttributeSet? = null可以为空
class MyView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {
。。。
}
Kotlin构造函数写法
最新推荐文章于 2024-04-01 17:06:31 发布