문제

I have a equation in string format like "45+5*4-6" which I have to solve in Java.

Is there any way to solve equation which is in string format?

도움이 되었습니까?

해결책

Check Beanshell

Something like this should work -

Interpreter ip = new Interpreter();
ip.eval("res = 45+5*4-6");
System.out.print(ip.get("res"));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top