SimpleBindings类的putAll()方法用于添加作为参数传递给SimpleBindings对象的Map的所有键值对。
Synatx:
public void putAll(Map toMerge)
参数:此方法接受参数toMerge,这是要添加的值的映射。
返回值:此方法不返回任何内容。
异常:此方法引发以下异常:
NullPointerException:如果toMerge映射为null或映射中的某些键为null。
IllegalArgumentException:如果映射中的某些键为空字符串。
下面是说明putAll()方法工作方式的程序:
程序1:
// Java programs to Illustrate
// the working of putAll() method
import javax.script.SimpleBindings;
import java.util.*;
public class GFG {
public static void main(String[] args)
{
// create simpleBindings object
SimpleBindings bindings = new SimpleBindings();
// create Map
HashMap map = new HashMap<>();
// add key value pair to Map
map.put("key1", "value1");