I need help with my code snippet:
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("JavaScript");
int x = 10;
engine.eval("x =" + x);
System.out.println((Boolean) engine.eval("x < 5"));
System.out.println((Boolean) engine.eval("2 < x < 5"));
The first System.out.println prints false as expected, but the second one prints true. It seems to be giving incorrect results when comparing a variable with two values. Is there a workaround for this issue? Any suggestions would be greatly appreciated. Thank you!