Here you can find the source of toMap(Object[] array)
public static Map toMap(Object[] array)
//package com.java2s; import java.util.HashMap; import java.util.Map; public class Main { public static Map toMap(Object[] array) { return toMap(array, null); }//from w w w. j a v a 2 s . c o m public static Map toMap(Object[] array, Map map) { if (array == null) { return map; } if (map == null) { map = new HashMap((int) (array.length * 1.5)); } for (int i = 0; i < array.length; i++) { Object object = array[i]; if (object instanceof Map.Entry) { Map.Entry entry = (Map.Entry) object; map.put(entry.getKey(), entry.getValue()); } else if (object instanceof Object[]) { Object[] entry = (Object[]) object; if (entry.length < 2) { throw new IllegalArgumentException( "Array element " + i + ", '" + object + "', has a length less than 2"); } map.put(entry[0], entry[1]); } else { throw new IllegalArgumentException( "Array element " + i + ", '" + object + "', is neither of type Map.Entry nor an Array"); } } return map; } }