What is toLowerCase() in Kotlin?

The toLowerCase() function in Kotlin converts a string to lowercase.

Visual representation of the toLowerCase() function

Syntax

String.toLowerCase()

Parameters

The toLowerCase() function does not take any parameters.

Return value

The toLowerCase() function returns the string that is converted to lowercase.

Example

In this example, we create two strings, str1 and str2. In line 5 and line 11, we use the toLowerCase() function to convert all the characters of the initial strings to lowercase.

fun main(args: Array<String>) {
// Example 1
val str1 = "EducatIvE"
print("After applying loLowerCase the result is : ")
print(str1.toLowerCase())
print("\n")
// Example 2
val str2 = "EdpResSo"
print("After applying loLowerCase the result is : ")
print(str2.toLowerCase())
print("\n")
}

Free Resources