Convert Postfix into Infix with numbers and characters
Numbers are split by space
Source: https://algorithms.tutorialhorizon.c...ix-expression/
package layout;
import java.util.Stack;
 
public class PostFixToInfix {
 
    public String convert(String expression){
 
        Stack<String> stack = new Stack<>();
        for (int i = 0; i <expression.length() ; i++) {
            char c = expression.charAt(i);
 
            if(c=='*'||c=='/'||c=='^'||c=='+'||c=='-' ){
                String s1 = stack.pop();
                String s2 = stack.pop();
                String temp = "("+s2+c+s1+")";
                stack.push(temp);
            }else{
                stack.push(c+"");
            }
        }
 
        String result=stack.pop();
        return result;
    }
 
    public static void main(String[] args) {
        String exp = "ABC/-AK/L-*";
        String exp1 = "3 5 7/-AK/L-*";
        System.out.println("Postfix Expression: " + exp);
        System.out.println("Infix Expression: " + new PostFixToInfix().convert(exp));
        System.out.println("Infix Expression: " + new PostFixToInfix().convert(exp1));
    }
}

Ouput:
Postfix Expression: ABC/-AK/L-*
Infix Expression: ((A-(B/C))*((A/K)-L))
(Error)
Infix Expression: ((5-( /7))*((A/K)-L))

How to fix this error?
Infix Expression: ((5-( /7))*((A/K)-L))