Kotlin - Null Safety
What is the problem with this Kotlin code?
var count: Int? = 5 count = null val total: Int = count + 10
var count: Int? = 5 count = null val total: Int = count + 10
count is declared as Int?, meaning it can be null.count + 10 is invalid because count might be null, and Kotlin does not allow arithmetic on nullable types without explicit handling.count?.plus(10) or count!! + 10 if sure not null.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions