In this tutorial, you shall learn how to convert a given string to lowercase in Kotlin, using String.lowercase() function, with examples.

Kotlin – Convert a String to Lowercase

To convert a string to lowercase in Kotlin, call lowercase() function on this string. lowercase() method returns a new string with all the characters in this string converted to lowercase.

Example

In the following example, we take a string in str, and convert this string into lowercase using lowercase() method.

Main.kt

fun main(args: Array<String>) {
    var str = "Hello World"
    var result = str.lowercase()
    println(result)
}

Output

hello world
ADVERTISEMENT

Conclusion

In this Kotlin Tutorial, we learned how to convert a given string into lowercase using String.lowercase() method, with the help of Kotlin example programs.