Java tutorial
//package com.java2s; //License from project: Apache License import java.util.LinkedHashMap; import java.util.Map; public class Main { @SuppressWarnings("unchecked") public static <T> Map<T, Object> asMap(T key, Object... values) { Map<T, Object> result = new LinkedHashMap<T, Object>(); if (values == null || values.length % 2 == 0) { throw new IllegalArgumentException("value[] must be not null and an odd length"); } result.put(key, values[0]); for (int i = 1; i < values.length; i += 2) { result.put((T) values[i], values[i + 1]); } return result; } }