title: trim.() method does not work(java)
body: <p>So i'm trying to count the characters in a String without the spaces. But somehow my trim() method doesn't cut the spaces:</p>
  
  <pre><code>class Test {
  
  HashMap&lt;Character, Integer&gt; testMap = new HashMap&lt;&gt;();
  
  public void encode(String text) {
      String code = text.trim();
      for (int i = 0; i &lt; code.length(); i++) {
          Character key = code.charAt(i);
          if (testMap.containsKey(key)) {
              testMap.put(key, testMap.get(key) + 1);
          } else {
              testMap.put(key, 1);
          }
  
      }
      System.out.println(testMap);
      System.out.println(code);
  }
  </code></pre>
  
  <p>Main method: </p>
  
  <pre><code>public class MyMain {
  
  public static void main(String[] args) {
      Test test = new Test();
      test.encode("Tessstttt faill");
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>So the output is:</p>
  
  <pre><code>{ =1, a=1, s=3, T=1, t=4, e=1, f=1, i=1, l=2}
  Tessstttt faill
  </code></pre>
  
  <p>Where is my mistake. Thanks a lot ahead!!
  (I'm not that experienced yet, so sorry in case of obvious mistake)</p>