Is there a java equivalent of the python eval function?

后端 未结 6 1610
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 07:59

Is there a java equivalent of the python eval function?

This would be a function which takes an arbitrary string and attempts to execute it in the current context.

6条回答
  •  庸人自扰
    2020-11-27 08:35

    The Java Scripting API is probably the closest to a standard way to execute strings as code in the JVM. JavaScript is supported in the Sun JVM out of the box, but isn't guaranteed to be supported by all JVM implementations.

提交回复
热议问题