Here you can find the source of toMap(K[] keys, V[] values)
public static <K, V> Map<K, V> toMap(K[] keys, V[] values)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; public class Main { public static <K, V> Map<K, V> toMap(K[] keys, V[] values) { HashMap<K, V> map = new HashMap<K, V>(); if (keys != null) { for (int i = 0; i < keys.length; i++) { map.put(keys[i], values != null ? (i < values.length ? values[i] : null) : null); }//from w w w . j a v a 2s . co m } return map; } }