In this article we will discuss how to capitalize first letter of each word in a String.Suppose given string is,

Now after converting first letter of each word, string will become,

This type of String is also called Camel Case.

Algorithm For Capitalizing First Letter of Each Word in String

  • Iterate over the string from beginning to end
    • For each character check its a white space or not.If its a white space then update a flag IS_SPACE true.
    • If its a character between ‘a’ to ‘z’ and flag IS_SPACE is true then just convert this character to upper case.

Complete code in Java is as follows,

 

 

Python Recommendations:

C++ & C++11 Recommendations:

If you didn't find what you were looking, then do suggest us in the comments below. We will be more than happy to add that.

Do Subscribe with us for more Articles / Tutorials like this,