title: Shunting yard algorithm in Java not working?
body: <p>Here is my code: </p>
  
  <pre><code>    public String ShuntingYard(String input) {
      Tokenizer tokens = new Tokenizer(input);
      output = new LinkedList&lt;String&gt;();
      stack = new MyStack&lt;String&gt;(new LinkedList&lt;String&gt;(), new LinkedList&lt;String&gt;());
  
      while (tokens.hasNextToken()){
          String token = tokens.getNextToken();
          if (isOperator(token)){
              while (!stack.isEmpty() &amp;&amp; isOperator(stack.peek())){
                      if ((leftassoc(token)&amp;&amp;precedence(token)&lt;=precedence(stack.peek())) ||
                              (precedence(token)&lt;precedence(stack.peek()))){
                          output.add(stack.pop());
                      }
                      else break; }
                      stack.push(token);
  
                  }
  
                  output.add(token); 
              }
          while (!stack.isEmpty())
              output.add(stack.pop());
  
          return output.toString();
  
          }
  </code></pre>
  
  <p>With an input 3 + 5 * 6 + 7, it's supposed to return 3 5 6 * + 7 +, but instead I get 3 + 5 * 6 + 7 + *. I'm confused as to why, since I followed the algorithm instructions on the Wikipedia page...am I messing up somewhere else? Thanks for the help in advance!</p>