Java tutorial
//package com.java2s; import java.util.*; public class Main { public static Map<Object, Object> collectionToMapUnsafe(Collection<?> keyCollection, Collection<?> valueCollection, Map<Object, Object> targetMap) { if (isEmpty(keyCollection)) { return targetMap; } if (valueCollection == null) valueCollection = new ArrayList<>(); Iterator<?> keyIterator = keyCollection.iterator(); Iterator<?> valueIterator = valueCollection.iterator(); while (keyIterator.hasNext()) { Object value = valueIterator.hasNext() ? valueIterator.next() : null; targetMap.put(keyIterator.next(), value); } return targetMap; } public static boolean isEmpty(Collection<?> collection) { return collection == null || collection.isEmpty(); } public static boolean isEmpty(Object[] array) { return array == null || array.length == 0; } }