Java tutorial
//package com.java2s; import java.util.*; public class Main { public static <K, V> Map<K, V> map(K[] keys, V[] values) { if (keys.length == values.length) { HashMap<K, V> result = new HashMap<K, V>(keys.length); for (int i = 0; i < keys.length; i++) { result.put(keys[i], values[i]); } return result; } else { throw new IllegalArgumentException("arrays must have equal length"); } } }