Java tutorial
//package com.java2s; import java.util.HashMap; import java.util.Map; public class Main { public static <K, V> Map<K, V> arraysToMap(K[] keys, V[] values) { if (keys.length != values.length) throw new RuntimeException("Lenght of keys: " + keys.length + ", length of values: " + values.length); Map<K, V> res = new HashMap<>(); for (int i = 0; i < keys.length; ++i) { res.put(keys[i], values[i]); } return res; } }