.lowercase()

abereFejiro9953409650's avatar
Published Jan 14, 2024
Contribute to Docs

The .lowercase() method in Kotlin changes all characters in a string to lowercase. It does not modify the original string, rather it returns a new transformed string. This is useful when case-sensitive operations are performed.

Syntax

String.lowercase()
  • String: The string to be converted to lowercase.

Example

The following example shows how to use the .lowercase() method on a string:

fun main() {
val originalString = "Hello, World!"
val newString = originalString.lowercase()
println("Original String: $originalString")
println("Lowercased String: $newString")
}

The above code will return the following output:

Original String: Hello, World!
Lowercased String: hello, world!

All contributors

Contribute to Docs

Learn Kotlin on Codecademy