title: removing White Spaces in String
body: <p>i have to get rid of <strong>more than 1 space </strong> that is if there is more than 1 space i had replaced it with single space. This is how i did it but i am  really confused which is the best way to do it and what is difference in all these. below is my code:</p>
  
  <pre><code>     public class SspaceDemo {
  
  public static void main(String[] as) {
      String s="  Hi this   space  Demo   ";
  
      String  s1 = s.replaceAll("\\s +", " ");
      System.out.println(s1.trim());
      String  s2 = s.replaceAll(" +", " ");
      System.out.println(s2.trim());
      String  s3 = s.replaceAll(" {2,}", " ");
      System.out.println(s3.trim());
  }
  }
  </code></pre>
  
  <p>which is the best way to achieve the result. please suggest.  Thanks,</p>