Kotlin - Null Safety
What will be the output of this Kotlin code?
fun printLength(str: String?) {
println(str!!.length)
}
printLength(null)fun printLength(str: String?) {
println(str!!.length)
}
printLength(null)!! operator forces the value to be non-null or throws an exception if null.str!! to throw a NullPointerException at runtime.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions