Convert String to Code

前端 未结 18 715
轮回少年
轮回少年 2020-11-22 09:27

I want to know if there is any way to convert a String to Java compilable code.

I have a comparative expression saved in a database field. I want to re

18条回答
  •  悲哀的现实
    2020-11-22 09:49

    If you're willing to sacrifice the "Java code" portion of your requirement, you could use the Java Mathematic Expression Evaluator library. It allows you to specify a math expression (as a java.lang.String), add values for the variables, and then evaluate the expression.

    I've used it in production code with great success.

提交回复
热议问题