the program is written for converting every first letter of the word to UpperCase
public class MainClass {
    public static void main(String[] args) {
        int i;
        String toBeCapped="";
        String str[] ={"This is a ball","This is a bat","this is the wicket"};
        int e=str.length;
        for(int j=0;j<e;j++)
        {
             String[] tokens = str[j].split("\\s");
             for( i = 0; i < tokens.length; i++)
             {
                 char capLetter = Character.toUpperCase(tokens[i].charAt(0));
                 toBeCapped +=  " " + capLetter + tokens[i].substring(1);
            }
            System.out.println(toBeCapped);
        }
    }
}
The output produced is as:-
This Is The Ball
This Is The Ball This Is The Bat
This Is The Ball This Is The Bat This Is The Wicket
I wanted the output to be as:-
This Is The Ball
This Is The 
This Is The Wicket
Please tell me what is the mistake I'm making. Thank You
 
     
     
     
     
    