16.8 Initializer Blocks
In addition to the primary and secondary constructors, a class may also contain initializer blocks which are called after the constructors. Since a primary constructor cannot contain any code, these methods are a particularly useful location for adding code to perform initialization tasks when an instance of the class is created. Initializer blocks are declared using the init keyword with the initialization code enclosed in braces:
class BankAccount (val accountNumber: Int, var accountBalance: Double) {
init {
// Initialization code goes here
}
.
.
}