0. 原文
https://www.runoob.com/kotlin/kotlin-class-object.html
1. 新建對象
fun main(args : Array<String>) {
var mStudent = Student("Jim", 18)
println("Student name is: ${mStudent.mName}, age is ${mStudent.mAge}")
}
// 構造器
class Student constructor(name: String, age : Int){
var mName = name
var mAge = age
init {
println("init $mName : $mAge")
}
}
運行示例
init Jim : 18
Student name is: Jim, age is 18
Process finished with exit code 0