CS Electrical And Electronics
@cselectricalandelectronics

Why question mark (?) is used while assigning string to null? In Kotlin

All QuestionsCategory: KotlinWhy question mark (?) is used while assigning string to null? In Kotlin
chetan shidling asked 3 years ago

fun main(args : Array<String>)
{
var str : String? = null
}

1 Answers
chetan shidling answered 3 years ago

It is used to assign null to string. If we assign null to string without using a question mark then it will show an error.