Here you can find the source of map(Object... args)
public static <K, V> Map<K, V> map(Object... args)
//package com.java2s; //License from project: Open Source License import java.util.Collections; import java.util.HashMap; import java.util.Map; public class Main { public static <K, V> Map<K, V> map(Object... args) { if (args.length % 2 != 0) throw new IllegalArgumentException("Length of arguments must be a multiple of 2"); else if (args.length == 0) return Collections.emptyMap(); Map<K, V> ret = new HashMap<>(args.length / 2); for (int idx = 0; idx < args.length; idx += 2) { //noinspection unchecked ret.put((K) args[idx], (V) args[idx + 1]); }/*ww w . j av a 2s. c o m*/ return ret; } }