Converting inserted string to a compilable expression

后端 未结 5 1808
醉梦人生
醉梦人生 2021-01-23 07:45

I\'m somehow new to Java so my question can seem trivial, however i cannot find an answer to it anywhere in my books.

I want to initiatie a dialog with a user in which h

5条回答
  •  伪装坚强ぢ
    2021-01-23 08:24

    It isn't so hard to parse them yourself, but if you need fast and probably accurate result, you can use one of the existing libraries to parse arithmetic expressions, like JEP or perhaps that Simple Parser for Arithmetic Expressions.

    See the Jep Console for a sample. It looks like Jep is payware. It might not be a problem, otherwise as I wrote, you should be able to find a number of equivalent libraries.

提交回复
热议问题