Class constructor
Basic usage of constructors
Class People(var age:Int,var name:String) {var age:Int,var name:String);Copy the code
Primary constructor default argument
Class People @jvmoverloads constructor(var age:Int,var name:String = "Kotlin")Copy the code
The main constructor
There can be only one primary constructor and multiple secondary constructors, but all secondary constructors must call the primary constructor directly or indirectly
Class constructor
Basic usage of constructors
Class People(var age:Int,var name:String) {var age:Int,var name:String);Copy the code
Primary constructor default argument
Class People @jvmoverloads constructor(var age:Int,var name:String = "Kotlin")Copy the code
The main constructor
There can be only one primary constructor and multiple secondary constructors, but all secondary constructors must call the primary constructor directly or indirectly