Here you can find the source of arrayAsMap(Object... t)
public static Map<String, Object> arrayAsMap(Object... t)
//package com.java2s; //License from project: Apache License import java.util.HashMap; import java.util.Map; public class Main { public static Map<String, Object> arrayAsMap(Object... t) { if (t == null || t.length <= 0) { return null; }// w w w. ja v a2s .co m if (t.length % 2 != 0) { throw new RuntimeException("illegal args count"); } Map<String, Object> params = new HashMap<String, Object>(t.length); for (int i = 0; i < t.length; i += 2) { if (t[i] == null || !t[i].getClass().equals(String.class)) { throw new RuntimeException("illegal arg: " + t[i] + "at " + i); } String key = t[i].toString(); Object value = t[i + 1]; params.put(key, value); } return params; } }