Create a Multiline String in Kotlin
To create a multiline String in Kotlin, enclose the multiline string value in triple double quotes.
For example consider the following string literal, where the string spans multiple lines, and is enclosed in triple double quotes.
"""This is
a multiline
string"""
You can assign this string value to a variable, or use it in an expression.
val message = """This is
a multiline
string"""
In the following program, we create a multiline string using triple double quotes, assign it to a variable, and print it to standard output.
Kotlin Program
fun main(args: Array<String>) {
val message = """This is
a multiline
string"""
println(message)
}
Output
This is
a multiline
string