- Kotlin Programming By Example
- Iyanu Adelekan
- 109字
- 2025-04-04 17:16:16
Char
This type is used to represent characters. A character is a unit of information that roughly corresponds to a grapheme, or a grapheme-like unit or symbol. In Kotlin, characters are of the Char type. Characters in single quotes in Kotlin, such as a, $, %, and &, are all examples of characters:
val c: Char = 'i' // I am a character
Recall we mentioned earlier that a string is a sequence of characters:
var c: Char
val sentence: String = "I am made up of characters."
for (character in sentence) {
c = character // Value of character assigned to c without error
println(c)
}