title: error in the given code for infix to postfix conversion for input containing more than 2 operands
body: <pre><code>  static String convert(String exp)
    {
      String result="";
      Stack s1=new Stack();
       for(int i=0;i&lt;exp.length();i++)
        {
         if(Character.isDigit(exp.charAt(i)))
         {{
         result=result+exp.charAt(i);
         continue;
         }
         else
         {
          if(s1.empty())
          {
           s1.push(exp.charAt(i));
            continue;
          }
          else
          {
           if(check(exp.charAt(i))&gt;check(exp.charAt(i-1)))
           s1.push(exp.charAt(i));
           else
          {
          while(!s1.empty())
          {
          String a=s1.pop().toString();
          result=result+a;
          }
          s1.push(exp.charAt(i));
          }
         }
        }
       }
      while(!s1.empty())
      {
      String p=s1.pop().toString();
      result=result+p;
      }
      return result;
    }
  
      static int check(char c)
      {
      switch (c) {
              case '+':
              case '-':
                  return 0;
              case '*':
              case '/':
                  return 1;
              case '^':
                  return 2;
              default:
                  throw new IllegalArgumentException("Operator unknown: " + c);
              }
      }
  </code></pre>
  
  <p>Here's my code to convert an expression from infix to postfix.
  This code is working fine with just 2 operands..for more than 2 operands like 6+9*7 it shows
   IllegalArgumentException which I have given in another method to set priorities of operators. Please help me to clarify where am I getting wrong?</p>