Here you can find the source of toMap(Object... objects)
@SuppressWarnings({ "rawtypes", "unchecked" }) public static Map toMap(Object... objects)
//package com.java2s; import java.util.HashMap; import java.util.Map; public class Main { @SuppressWarnings({ "rawtypes", "unchecked" }) public static Map toMap(Object... objects) { Map map = new HashMap(); for (int i = 0; i < objects.length; i += 2) { map.put(objects[i], objects[i + 1]); }/* w ww.ja v a 2 s . co m*/ return map; } }