1.什么都沒有,在該類中使不能使用的, 這個參數的作用就是,傳遞給父類的構造方法
2.使用var 可以在類中使用,相當於 我們聲明了一個該類中定義了一個private 的成員變量
3.val表示不讓修改該參數 加上了final 修飾符
class Glory (str:String , nom:Int){
} 轉為Java代碼
public final class Glory { public Glory(@NotNull String str, int nom) { Intrinsics.checkParameterIsNotNull(str, "str"); super(); } }
class GloryHH(str: String, val nom: Int) 轉為kotlin代碼
public final class GloryHH { private final int nom; public final int getNom() { return this.nom; } public GloryHH(@NotNull String str, int nom) { Intrinsics.checkParameterIsNotNull(str, "str"); super(); this.nom = nom; } }