Capitalize the each words in sentence of kotlin (Capitalize method getting deprecated)

fun main(args: Array<String>) {
/* Capitalize first letter
in each word*/
val str = "kotlin is programing language"
val words = str.split(" ")
val result = words.map {
it.replaceFirstChar {
it.uppercase()
}
}
println(result.joinToString(" "))
}
view raw gistfile1.txt hosted with ❤ by GitHub
 

Comments

Popular posts from this blog

Your build is currently configured to use incompatible Java 21.0.3 and Gradle 8.2.1. Cannot sync the project.

Google Assistant Implementation in Android application with app actions