我在我的项目中使用 MxParser 库。我在下面写了 3 种不同的方式。前两个有效,但第三个(我真正想要的)无效
1) (working)
Argument x=new Argument("x",2);
Argument y=new Argument("y",3);
Argument z=new Argument("z",4);
Expression e2=new Expression("(y-x)*100",x,y,z);
String result=String.valueOf(e2.calculate());
System.out.println("result= "+result);
2) (working)
HashMap<String, Argument> map4 = function_2(list);
Entry<String, Argument> next4 = map4.entrySet().iterator().next();
Argument a = next4.getValue();
String formula="(A+A)*100";
Expression e = new Expression(formula,a);
System.out.println("result= " + e.calculate());
3) (not working)
HashMap<String, Argument> map4 = function_2(list);
Entry<String, Argument> next4 = map4.entrySet().iterator().next();
Argument a = next4.getValue();
String formula="(A+A)*100";
String s=","; // This line is Dİfferent
Expression e = new Expression(formula+s+a); // This is too
System.out.println("result= " + e.calculate());
慕侠2389804
汪汪一只猫
相关分类