Here you can find the source of createMap(Object... objects)
Parameter | Description |
---|---|
objects | Keys and values |
@SuppressWarnings("unchecked") public static <T, X> Map<T, X> createMap(Object... objects)
//package com.java2s; //License from project: Apache License import java.util.HashMap; import java.util.Map; public class Main { /**//from w ww.ja v a 2 s .c o m * Create Map filled with values. First value of array is key, second is the value, third is key... * * @param objects * Keys and values * @return HashMap filled. */ @SuppressWarnings("unchecked") public static <T, X> Map<T, X> createMap(Object... objects) { Map<T, X> map = new HashMap<>(); for (int i = 0; i < objects.length; i++) { map.put((T) objects[i], (X) objects[++i]); } return map; } }