Posted on 30th April 2025|45 views
How to null check in kotlin?
Posted on 30th April 2025| views
The standard method of checking reference of null is by utilizing the if-else expression. We can explicitly check the null variable, also manage the two options independently.
Program for checking null conditions:
fun main(args: Array<String>) {
var m: String? = "mindmajix"
println(s)
if (m != null) {
println("length of the string ${m.length}")
} else {
println("it is a null string")
}
m = null
println(m)
if (m != null) {
println("length of the string ${m.length}")
} else {
println("it is a null string")
}
}