Java Map Put putMap(Map map, Object... args)

Here you can find the source of putMap(Map map, Object... args)

Description

Add entries to a Map.

License

Open Source License

Parameter

Parameter Description
map The map where entries are added.
args An even number of objects. The objects at index 0, 2, 4, ... are the keys, the objects at index 1, 3, 5 are the values.

Declaration

public static void putMap(Map map, Object... args) 

Method Source Code

//package com.java2s;
/*//w  w  w .j a v  a2s  .  c o m
** Copyright 2009-2014 by LivingLogic AG, Bayreuth/Germany
** All Rights Reserved
** See LICENSE for the license
*/

import java.util.Map;

public class Main {
    /**
     * Add entries to a Map.
     * @param map The map where entries are added.
     * @param args An even number of objects. The objects at index 0, 2, 4, ...
     *             are the keys, the objects at index 1, 3, 5 are the values.
     */
    public static void putMap(Map map, Object... args) {
        int pos = 0;
        Object key = null;
        for (Object arg : args) {
            if ((pos & 1) != 0)
                map.put(key, arg);
            else
                key = arg;
            ++pos;
        }
    }
}

Related

  1. putIntoMap(String key, Object value)
  2. putItem(Map map, Object key, Object value)
  3. putKV(Map map, String k, Object v)
  4. putLong(Map properties, String key, long value)
  5. putLowerNotNull(Map m, String k, V v)
  6. putMap(Map target, Map map)
  7. putMapBoolean(Map params, String key)
  8. putMapBooleanList(Map params, String... keys)
  9. putMapByPair(String pair, Map m)