0

I want to get a String from the user like "System.out.println(\"Hello World!\");" or "int x = 2;" and then execute that input at runtime in java, I know that in python there is a built in function called exec() that do what exactly what I want here.

thakee nathees
  • 877
  • 1
  • 9
  • 16
  • 1
    Although Python's `eval()` and `exec()` are not identical, they are close enough for this purpose that the answer is the same. Especially since it's "no". – John Bollinger Feb 21 '19 at 12:53
  • 2
    Java is a compiled language, Python is an interpreted one. For Java is not a simple task to do compilation on the fly. – Ervin Szilagyi Feb 21 '19 at 12:54

0 Answers0