Monday, November 11, 2013

JAVA CODE TO TEST A CONDITION STORED INTO A STRING VARIABLE

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public class TestCondition {
   public static void main(String[] bag) throws Exception {
                  ScriptEngineManager factory = new ScriptEngineManager();
                  ScriptEngine engine = factory.getEngineByName(“JavaScript”);
                  String condition = “10==10 && 20==20″;
                  System.out.println(engine.eval(condition));
     }
}

No comments:

Post a Comment