Here you can find the source of toMap(Object... args)
public static Map<String, Object> toMap(Object... args)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; public class Main { public static Map<String, Object> toMap(Object... args) { if (args.length % 2 == 1) throw new RuntimeException("toMap must be called with an even number of parameters"); HashMap<String, Object> map = new HashMap<String, Object>(); for (int i = 0; i < args.length; i += 2) { String key = "" + args[i]; Object value = args[i + 1]; map.put(key, value);//from www. j a va 2 s . c o m } return map; } }