Kotlin Program using secondary constructor


In this program, You will learn how to implement a secondary constructor in Kotlin.


constructor() { 
    //constructor
}

Example: How to implement a secondary constructor in Kotlin.

class Test {
   constructor() {
       println("Secondary constructor is called here")
   }
}

fun main(args: Array<String>) {
   var obj = Test()
}

Output:

Secondary constructor is called here