Here you can find the source of newHashMap(K[] keys, V[] values)
public static <K, V> HashMap<K, V> newHashMap(K[] keys, V[] values)
//package com.java2s; //License from project: Apache License import java.util.HashMap; public class Main { public static <K, V> HashMap<K, V> newHashMap(K[] keys, V[] values) { if (keys.length > values.length) { throw new IllegalArgumentException("Values is less than keys"); }// w ww .j av a 2s . c om HashMap<K, V> map = new HashMap<>(); for (int i = 0; i < keys.length; i++) { map.put(keys[i], values[i]); } return map; } }