What is toUpperCase() in Kotlin?
The toUpperCase() function converts a string to uppercase.
Syntax
String.toUpperCase()
Parameters
The toUpperCase() function does not take any parameters.
Return value
The toUpperCase() function returns the string that is converted to uppercase.
Example
Let’s look at an example. In this example, we create two strings, str1 and str2. Then, we use the toUpperCase() function in line 5 and line 11 to capitalize all the characters in our strings.
fun main(args: Array<String>) {// Example 1val str1 = "Educative"print("After applying toUpperCase the result is : ")print(str1.toUpperCase())print("\n")// Example 2val str2 = "Edpresso"print("After applying toUpperCase the result is : ")print(str2.toUpperCase())print("\n")}