import java.util.LinkedList; public class Calc { LinkedList operList = new LinkedList(); LinkedList numList = new LinkedList(); String oper1 = "+-"; String oper0 = "*/"; /** * @param args */ public static void main(String[] args) { String exp = "(32/((8+2)-6)-6)*3"; Calc c = new Calc(); try { System.out.println(c.calc(c.replceKuoHao(exp))); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } // System.out.println(c.calc(exp)); } // 有括号,先计算括号里边的.括号不作为运算符 public String replceKuoHao(String exp1) throws Exception { StringBuffer exp = new StringBuffer(exp1); if (exp.indexOf("(") > -1) { if (exp.indexOf(")") < 0) { throw new Exception("Expressation format error, loss KuoHao!"); } else { while (exp.indexOf("(") > -1)