Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javax.script.Bindings;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class Main {
    public static void main(String[] args) {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("JavaScript");

        Bindings params = engine.createBindings();

        params.put("stringKey", "Hello");
        params.put("valueKey", 2015);

        Object msg = params.get("stringKey");
        Object year = params.get("valueKey");
        System.out.println("stringKey" + msg);
        System.out.println("valueKey = " + year);

        params.remove("valueKey");
        year = params.get("valueKey");

        boolean containsYear = params.containsKey("valueKey");
        System.out.println("valueKey = " + year);
        System.out.println("params contains year = " + containsYear);
    }
}