Need Assistance?

support@tutorialshub.in

Null Safety (Kotlin's Superpower)

Nullable (String?) vs Non-Nullable (String)

ADVERTISEMENT
Kotlin Free Lesson
5 min read
ADVERTISEMENT

By default, Kotlin variables cannot hold null. Writing var name: String = null won't even compile! To allow null, append a question mark (String?)—and Kotlin forces you to handle the null case before accessing properties like .length.

ADVERTISEMENT
Hi, I'm Tuby! Here to help you