Converting inserted string to a compilable expression

后端 未结 5 1821
醉梦人生
醉梦人生 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:19

    You could also look at JScheme. Need to compile & run with the jscheme jar file.

    import jscheme.JS; 
    
    String query = "(+ 10 20)";
    System.out.println(query + " = " + JS.eval(query));
    

    See third example down at http://jscheme.sourceforge.net/jscheme/doc/userman.html#si

    JScheme main page at http://jscheme.sourceforge.net/jscheme/main.html

提交回复
热议问题