Problem Statement
A common word-processing task is capitalizing the first letter of each word in a title. Write a class TitleString with a method toFirstUpperCase that takes a String title containing lowercase words separated by one or more space characters and returns a String that is identical to title except with the first character of each word capitalized.
Definition
- Class:
- TitleString
- Method:
- toFirstUpperCase
- Parameters:
- String
- Returns:
- String
- Method signature:
- String toFirstUpperCase(String title)
- (be sure your method is public)
Notes
- title may have leading or trailing spaces.
Constraints
- title will contain between 0 and 50 characters, inclusive.
- Each character of title will either be a space or a lowercase letter ('a' to 'z').
Examples
"introduction to algorithms"
Returns: "Introduction To Algorithms"
"more than one space between words"
Returns: "More Than One Space Between Words"
" lord of the rings the fellowship of the ring "
Returns: " Lord Of The Rings The Fellowship Of The Ring "
" "
Returns: " "
"i"
Returns: "I"
"the king and i"
Returns: "The King And I"
""
Returns: ""