Characters

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()
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.177.222