title: Postfix evaluation for multidigit numbers
body: <p>I as programming a postfix evaluator, and I was able to do it correctly for single digit number.
  Now I need an idea of how to do it for multiple digit number, as my current program evaluates a two digit number as different numbers.</p>
  
  <p>Here's the code :</p>
  
  <pre><code>public class PostfixEvaluation {
  
      public static void main(String[] args) {
          String postfix = "23+79*-";
  
          Stack stack = new Stack();
  
          for (int i = 0; i &lt; postfix.length(); i++) {
              if (postfix.charAt(i) == '+') {
                  int v1 = stack.pop();
                  int v2 = stack.pop();
                  stack.push(v2 + v1);
              } else if (postfix.charAt(i) == '-') {
                  int v1 = stack.pop();
                  int v2 = stack.pop();
                  stack.push(v2 - v1);
              } else if (postfix.charAt(i) == '*') {
                  int v1 = stack.pop();
                  int v2 = stack.pop();
                  stack.push(v2 * v1);
              } else if (postfix.charAt(i) == '/') {
                  int v1 = stack.pop();
                  int v2 = stack.pop();
                  stack.push(v2 / v1);
              } else if (postfix.charAt(i) == '^') {
                  int v1 = stack.pop();
                  int v2 = stack.pop();
                  stack.push((int) Math.pow(v2, v1));
              } else {
                  stack.push((int) postfix.charAt(i) - 48);
              }
          }
          System.out.println(stack.pop());
      }
  
  }
  </code></pre>