This article explores different ways to get lowercase and uppercase representation of a string in Kotlin.

The recommended solution to convert all characters in the string to uppercase is using the toUpperCase() function. A typical invocation for this method would look like:

Download Code

 
To convert all characters in the string to lowercase, use toLowerCase() function:

Download Code

 
Both toUpperCase() and toLowerCase() function accepts a Locale. It changes the case of the string using the rules of the specified locale. Its usage is demonstrated below.

Download Code

That’s all about getting lowercase and uppercase representation of a string in Kotlin.