title: How to write a Java program to include whitespaces at the beginning of a string that we want to reverse?
body: <p>I want to reverse a string.
  input:    Computer;
  This input contains 4 whitespaces in the beginning of the word 'computer'.I want to include these 4 whitespaces in the beginning of the reversed string also.So,the program should include all the whitespaces I put at the beginning while taking the reverse too(I put 4 whitespaces as an example only).
  output:&quot;    retupmoc&quot;;
  I am attaching my code here.</p>
  <pre><code>package BasicTesting;
  import java.util.*;
  
      public class Corrected_StringRev {
      
          public static void main(String[] args) {
              Scanner sc= new Scanner(System.in); //System.in is a standard input stream  
              System.out.print(&quot;Enter a string: &quot;);  
              String str= sc.nextLine();        
              String reversed = reverseString( str );
              
              System.out.println( reversed );
          }
          
          public static String reverseString( String newString ) {
              
              char ch[]=newString.toCharArray();  
              String rev=&quot;&quot;;  
              for(int i=ch.length-1;i&gt;=0;i--){  
                  rev+=ch[i];  
              }  
              return rev;  
         
          }
      }
  </code></pre>
  <p>How can I change this code to include the above requirement.Please,rewrite the code.Hope ypu will help.Thanks in adavance!</p>