I have a problem understanding how class parameter value behaves between abstract/concrete classes.
Abstract class example:
abstract class A {
init {
initStuff()
}
fun initStuff() {
additionalInit()
}
abstract fun additionalInit()
}
Concrete class example:
class B(val exParam: Int): A {
init {
println("$exParam") // This would give expected value.
}
override fun additionalInit() {
println("$exParam") // Always zero even if exParam value is set.
}
}
My question is that based on my understanding, I want to call B(1000)
and expect both println
inside the B class to print 1000
but this was not the case so my understanding is clearly off here so anyone can light me to the right understanding?