Search⌘ K
AI Features

Characters and Strings

Explore how Kotlin handles characters and strings, including the Char type, Unicode representation, escape sequences, multiline strings, and string templates. This lesson helps you understand text manipulation and formatting in Kotlin, essential for building robust applications.

We'll cover the following...

Characters

To represent a single character, we use the Char type. We specify a character using single quotes (').

Kotlin 1.5
fun main() {
println('A') // A
println('Z') // Z
}

Each character is represented as a Unicode number. To find out the Unicode of a character, we use the code property.

Kotlin 1.5
fun main() {
println('A'.code) // 65
}

Kotlin accepts Unicode characters. To describe them by their code, we start with ...