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

Kotlin – Convert a String to Uppercase

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

Example

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

Main.kt

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

Output

HELLO WORLD

Conclusion

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