close
函數預測參數
class testClass(val custmerName:String="bill",var value:Float=20.4F){ //預設參數
init {//主建構元跑的地方
Log.d("test", "init:" + custmerName + ":" + value)
}
constructor(twoValue: Int) : this() {//第二建構式..this是啟用init..如果class有宣告參數的話就必放)
Log.d("test", "constructor:"+twoValue)
}
}
在其他class執行class第二建構式
testClass(123)
輸出
init:bill:20.4
constructor:123
全站熱搜
留言列表