Characters

Occasionally, we need to deal with individual characters, not longer strings. Characters can be represented by very short strings, if desired. However, just as Java has char and Character to represent individual characters, Kotlin too has a Character class.

In Kotlin, as with Java, a Character literal is represented by a single-quoted character:

  println('a')

Also, similar to Java, escape sequences can be used for individual characters, much as they can with strings.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.