Here you can find the source of map(Object... keyvals)
@SuppressWarnings("unchecked") public static <K, V> Map<K, V> map(Object... keyvals)
//package com.java2s; //License from project: Apache License import java.util.Collections; import java.util.HashMap; import java.util.Map; public class Main { @SuppressWarnings("unchecked") public static <K, V> Map<K, V> map(Object... keyvals) { if (keyvals == null) { return new HashMap<>(); } else if (keyvals.length % 2 != 0) { throw new IllegalArgumentException( "Map must have an even number of elements"); } else {//from www.j av a2 s. com Map<K, V> m = new HashMap<>(keyvals.length / 2); for (int i = 0; i < keyvals.length; i += 2) { m.put((K) keyvals[i], (V) keyvals[i + 1]); } return Collections.unmodifiableMap(m); } } }