Java tutorial
//package com.java2s; import java.util.HashMap; public class Main { @SafeVarargs public static <T> HashMap<T, T> kvMap(T... kvPairs) { HashMap<T, T> map = new HashMap<>(); for (int i = 0; i < kvPairs.length; i += 2) { map.put(kvPairs[i], kvPairs[i + 1]); } return map; } }