kotlin Null Safety

  1. Declare a variable with a nullable type: var name: String? = "John"

  2. Use safe call operator to access property of a nullable variable: val length = name?.length

  3. Use the elvis operator for handling null values: val lengthOrDefault = name?.length ?: 0

  4. Perform a null check with the safe call and let: name?.let { println("Name is not null: $it") }