Java Utililty Methods List to Map

List of utility methods to do List to Map

Description

The list of methods to do List to Map are organized into topic(s).

Method

MaplistToMap(final String... strings)
list To Map
final Map<String, String> map = new LinkedHashMap<>();
final Iterator<String> stringIterator = Arrays.asList(strings).iterator();
while (stringIterator.hasNext()) {
    final String key = stringIterator.next();
    final String value = stringIterator.next();
    map.put(key, value);
return map;
...
MaplistToMap(List input)
list To Map
int sz = input.size();
Map<String, Object> output = new LinkedHashMap<>();
for (int i = 0; i < sz; i++) {
    output.put("idx_" + i, input.get(i));
return output;
MaplistToMap(List> list)
Converts a list of two element lists (key, value) into a map.
Map<T, T> map = new HashMap<T, T>(list.size());
Iterator<List<T>> i = list.iterator();
while (i.hasNext()) {
    List<T> l = i.next();
    map.put(l.get(0), l.get(1));
return map;
MaplistToMap(List> list)
Puts the entries in list into a Map .
Map<A, B> result = new LinkedHashMap<A, B>();
for (Iterator<Map.Entry<A, B>> it = list.iterator(); it.hasNext();) {
    Map.Entry<A, B> entry = (Map.Entry<A, B>) it.next();
    result.put(entry.getKey(), entry.getValue());
return result;
MaplistToMap(Object... objects)
list To Map
HashMap map = new HashMap();
Object key = null;
for (final Object object : objects) {
    if (key == null) {
        key = object;
    } else {
        map.put(key, object);
        key = null;
...