Kotlin – Create an Empty String

Create an Empty String in Kotlin

1. Using Double Quotes

To create an empty String in Kotlin, use enclosing double quotes with not character specified between the quotes.

""

And you can assign this empty string to a variable.

val emptyString = ""

2. Using String() Constructor

You can also use String class constructor. Call String() and pass no argument. The constructor returns an empty String.

val emptyString = String()