Loading...
Loading...
Loading...
Names on an admission list were typed in random case, with extra spaces. Print each name in title case: the first letter of every word capital, the rest small, and exactly one space between words.
Example 1
Input
rAVI kumar sharma
Output
Ravi Kumar Sharma
Example 2
Input
anita DESAI
Output
Anita Desai
Extra spaces are dropped.
Try the problem first. Open one hint at a time.
Use trim() and then split("\\s+") to get the words.
For each word: substring(0, 1).toUpperCase() plus substring(1).toLowerCase().
Put a space before every word except the first.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor