Characters and Strings

Reading Time: < 1 minuteKotlin characters and strings are exactly the same things as Java strings. You can pass a char/string created in Kotlin code to any Java method, and you can use any Kotlin standard library methods on chars/strings that you receive from Java code. No conversion is involved, and no additional wrapper ojbects are created.

In Kotlin characters are represented by the type Char.

The String class represents character strings.
All String literals in Kotlin programs, such as “abc”, are implemented as instances of this class.

Be careful, Kotlin is case sensitive.
Single quotes are used for Characters
Double quotes are used for String.

Curiosity

If you convert Char to Int, then you will get the position of the character in the ASCII table.
It is valid inversel also.


 

Follow and like us:

Click to rate this post!
[Total: 1 Average: 5]

Leave a comment

stay informed!

Subscribe to receive exclusive content and notifications