Posted on 19th April 2024
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")
}
}
STILL GOT QUERIES?