Kotlin String capitalize

String.capitalize() returns a copy of this string having its first letter upper-cased.

String.capitalize() returns the original string, if it’s empty or already starts with an upper-case letter.

To capitalize first character of each word in the given sentence, refer the second example provided below.

Example – String capitalize first letter

Example – String capitalize first letter for each word in the sentence


In this Kotlin TutorialKotlin String Capitalize, we have learnt how to use to capitalize() function to convert first character of a String or each word of String to uppercase with examples.