kotlin 构造函数重载
构造函数重载 (Constructor Overloading)
A Kotlin class has a primary constructor and one or more secondary constructors. When a class has more than one constructor, it will be known as constructor overloading.
Kotlin类具有一个主构造函数和一个或多个辅助构造函数。 当一个类具有多个构造函数时,将称为构造函数重载。
Kotlin中用于构造函数重载的程序 (Program for constructor overloading in Kotlin)
package com.includehelp
//declare Class with Parameterized primary constructor
class ConstructorOverloading(len:Int){
//Init block, executed when class is instantiated,
//before secondary constructor body execution
init {
println("Init Block : $len")
}
//Secondary Constructor,
//delegate primary constructor with 'this'