Java tutorial
//package com.java2s; import java.util.HashMap; import java.util.Map; public class Main { public static <T> Map<String, T> asMap(T... values) { Map<String, T> result = new HashMap<String, T>(); if (values.length % 2 != 0) { throw new RuntimeException("invalid params length"); } if (values.length > 0) { for (int i = 0; i < values.length; i += 2) { result.put(values[i].toString(), values[i + 1]); } } return result; } }