title: Mysterious Whitespace with Stringbuilder
body: <p>I'm writing a little calculator application and use a simple tokenizer to parse the user input into a list for subsequent processing. </p>
  
  <p>The method looks like this:</p>
  
  <pre><code>public LinkedList&lt;String&gt; tokenize(String infix) throws Exception 
  {
      LinkedList&lt;String&gt; tokens = new LinkedList&lt;String&gt;();
      StringBuilder operand = new StringBuilder("");
  
      char current;
  
      int index = 0;
      while(index &lt;= infix.length() -1) {
          current = infix.charAt(index);
  
          if(!isOperator(current)) {
              operand.append(current);
          } else {
              // Add the operand stack
              tokens.add(operand.toString());
              operand = new StringBuilder("");
              // Add the operator
              tokens.add(Character.toString(current));
          }
          index++;
      }
      // The trailing operator
      tokens.add(operand.toString());
      return tokens;
  }
  </code></pre>
  
  <p>The test I've set up for this method, looks like this:</p>
  
  <pre><code>public void testTokenizer() throws Exception 
  {   
      LinkedList&lt;String&gt; list = parser.tokenize("35+35");
      assertTrue(list.get(0) == "35" &amp;&amp;
          list.get(1) == "+"  &amp;&amp;
          list.get(2) == "35");
  }
  </code></pre>
  
  <p>However, this fails because the tokenizer seems to add whitespace to the tokens. For example, printing the list tokenized from the string "35+35" gives me:</p>
  
  <pre><code>[35, +, 35]
  </code></pre>
  
  <p>What's going on here?</p>