How to create an object from a string in Java (how to eval a string)?

前端 未结 7 2054
醉梦人生
醉梦人生 2020-12-03 13:08

I know eval is \"evil\", but I\'m using it in a way that the user can\'t ever abuse it.

Let\'s say I\'ve got a string \"new Integer(5)\". I want to do something suc

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 13:52

    Java is a statically typed language, so I don't think you can do that.

提交回复
热议问题