Java HashMap Create hashMap(Entry... entries)

Here you can find the source of hashMap(Entry... entries)

Description

hash Map

License

Apache License

Declaration

public static <K, V> Map<K, V> hashMap(Entry<K, V>... entries) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;

import java.util.Map;
import java.util.Map.Entry;

public class Main {

    public static <K, V> Map<K, V> hashMap(Entry<K, V>... entries) {
        return hashMap(Arrays.asList(entries));
    }//from w  w w  .ja  v a  2 s  . com

    public static <K, V> Map<K, V> hashMap(Collection<Entry<K, V>> entries) {
        if (entries == null || entries.size() == 0) {
            return Collections.EMPTY_MAP;
        }
        HashMap<K, V> map = new HashMap<K, V>(entries.size());
        for (Entry<? extends K, ? extends V> entry : entries) {
            map.put(entry.getKey(), entry.getValue());
        }
        return map;
    }
}

Related

  1. getHashMapFromArrayList( ArrayList lines, int keyIndex)
  2. getHashMapFromMap( Map map, K key)
  3. hashMap()
  4. hashMap()
  5. hashmap()
  6. hashMap(Entry... entries)
  7. hashMap(Object... kvs)
  8. hashMapRange(int upTo)
  9. newHashMap( Map map)