is it possible to execute a String as a line of code? for example, could have:
String command = "x+=2";
and then have somehow run that string as though it were a line of code? im trying to make an action listener add "Requests" to an arraylist that will be executed in an orderly way at a time perhaps more appropriate than when the event occurs, and i dont know any other way to "put off" the execution of some code while keeping the rest of the program running. if you'd like, i can post the full code if my explanation didnt make anysense thanks for any help, guys
You would have to scan it with a scanner, eg lex, flex, JFlex, then pass the resultant tokens to a parser eg yacc, bison, byacc, CUP, and set up TACs (triple address codes), or put executable code into the parser.
Get yourself a book about compiler design, because that is what you are doing. Yes, it is possible; that is what happens when an application is compiled, but it is well beyond the beginner's level. You will find computer sciences courses include modules about "languages" or "compilers;" that si the sort of thing they cover.