title: reverse every word of the sentence..the changes do not appear
body: <p>this is a simple program to reverse each word of the string  and print ... i dont know whats going wrong with this...please help</p>
  
  <pre><code>import java.util.Scanner;
  
  
  public class ReverseWordCapitalizeFirstCharacter {
  
  
      public static void reverse(char a[], int start, int  end)
      {   
          while(start&lt;end)
          {
          char temp = a[start];
          a[start] = a[end];
          a[end] = temp;
          start++;
          end--;
          }
      }
  
      public static void main(String[] args) {
  
          System.out.println("Enter the string");
          Scanner sc = new Scanner(System.in);
          String str = sc.next();
  
          char a[] = new char[str.length()];
          a = str.toCharArray();
          int wordStartIndex = 0;
  
          for(int i=0; i&lt;a.length; i++)
          {
                  if(a[i] == ' ')
                  {  
                      reverse(a,wordStartIndex,i-1);  
                       wordStartIndex = i+1;
                  }
  
          }
  
          for(int i=0; i&lt;a.length; i++)
          {
              System.out.print(a[i]);
          }
  
      }
  
  }
  </code></pre>
  
  <p>i am passing the character array as parameter to the function that reverse each word..</p>