title: How to convert type Object from engine.eval to type int
body: <p>My program takes a String input and calculates it using <code>engine.eval()</code> from ScriptEngine imports. How do I convert the evaluated value to type int?</p>
  
  <pre><code>import javax.script.ScriptEngine;
  import javax.script.ScriptEngineManager;
  import javax.script.ScriptException;
  
  public class Main {
  
  public static void main(String[] args) {
  
      String s = "206 + 4";
      Object eval;
  
      ScriptEngineManager mgr = new ScriptEngineManager();
      ScriptEngine eng = mgr.getEngineByName("JavaScript");
  
      try {
          eval = eng.eval(s);
      } catch (ScriptException e) {
          System.out.println("Error evaluating input string.");
      }
  
  //Convert Object eval to int sum
  }
  }
  </code></pre>