August 2018
Beginner
178 pages
4h 56m
English
Characters in Kotlin are represented with Char type. The character literal is declared with a single quote:
val a: Char = 'a'
There are not many differences from Java's char type, except that the Kotlin Standard Library adds several extension methods that make working with the Char type easier. For example, you can get a number type representation of a char with these functions. Here's how you'd get an Int value from a Char:
val num: Int = 'a'.toInt()
Read now
Unlock full access