Java 调用 泛型方法

 

 

 

 

 

public static  Map mapThem(String[] keys, V... vals) {
	if (keys == null || keys.length == 0) {
		return new HashMap(4);
	}
	Map map = new HashMap(keys.length + 1);
	for (int i = 0; i < keys.length; i++) {
		if (vals.length > i) {
			map.put(keys[i], vals[i]);
		}
		else {
			map.put(keys[i], null);
		}
	}
	return map;
}

 

Map map = MapUtil. mapThem(new String[] { "datetime" }, timeline);

 

 

 

 

 

你可能感兴趣的:(Java)