Convert infix to postix and evaluate expression in Java
<p>I am supposed to write program to convert infix notation to postfix notation using stacks in Java. I'm pretty much done, but am getting an error. Here is the code as of now: </p>

<pre><code>import java.util.Scanner;
import java.util.Stack;

public class InfixToPostfix {
  private String infix;
  private String postfix = "";

  public void convertString (String a){
    String str = "";
    infix = a;
    Stack&lt;String&gt; stack = new Stack&lt;String&gt;();

    for (int i = 0; i &lt; infix.length(); i++){
      str = infix.substring(i,i+1);
      if(str.matches("[a-zA-Z]|\\d"))
        postfix += str;
      else if (isOperator(str)){
        if (stack.isEmpty()){
          stack.push(str);
        }
        else{
          String stackTop = stack.peek();
          while (getPrecedence(stackTop,str).equals(stackTop)
                 &amp;&amp; !(stack.isEmpty())){
            postfix += stack.pop();
            if (!(stack.isEmpty()))
              stackTop = stack.peek();
          }
          stack.push(str);
        }
      }
    }
    while(!(stack.isEmpty()))
      postfix += stack.pop();
    System.out.println("The postfix form of the expression you entered is: " +
                       postfix);
  }

  private boolean isOperator(String ch){
    String operators = "*/%+-";
    if (operators.indexOf(ch) != -1)
      return true;
    else
      return false;
  }

  private String getPrecedence(String op1, String op2){
    String multiplicativeOps = "*/%";
    String additiveOps = "+-";
    if ((multiplicativeOps.indexOf(op1) != -1) &amp;&amp; (additiveOps.indexOf(op2) != -1))
      return op1;
    else if ((multiplicativeOps.indexOf(op2) != -1) &amp;&amp; (additiveOps.indexOf(op1) != 
                                                        -1))
      return op2;
    else if((multiplicativeOps.indexOf(op1) != -1) &amp;&amp; (multiplicativeOps.indexOf   
                                                       (op2) != -1))
      return op1;
    else
      return op1;
  }
  public static void main(String[] args) {

    System.out.println("Enter an expression in the Infix form:");
    Scanner scanner = new Scanner(System.in);

    String expression = scanner.nextLine();
    new convertString (expression);

  } 
}
</code></pre>

<p>The error is on the very last line and says: </p>

<p>"Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    convertString cannot be resolved to a type</p>

<pre><code>at InfixToPostfix.main(InfixToPostfix.java:62)"
</code></pre>

<p>Any ideas as to how to fix this? What am I doing wrong?</p>

<p>EDIT: I got my code working and it is successfully converting infix to postfix, but is there any way I can get it to also evaluate the expression and spit out the answer? For example if the input was 2+3 then it would convert it to 23+ and then spit out 5 as well.</p>
