Here you can find the source of putMap(Map map, Object... args)
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. |
public static void putMap(Map map, Object... args)
//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; } } }