Java HashMap Create toHashMap(final Map map)

Here you can find the source of toHashMap(final Map map)

Description

to Hash Map

License

Open Source License

Declaration

public final static <K, V> HashMap<K, V> toHashMap(final Map<K, V> map) 

Method Source Code

//package com.java2s;

import java.util.HashMap;

import java.util.Map;

public class Main {
    public final static <K, V> HashMap<K, V> toHashMap(final Map<K, V> map) {

        if (map instanceof HashMap) {
            // cast to it
            return (HashMap<K, V>) map;
        } else {/*  ww  w . j av a  2 s . c om*/
            // create new
            return new HashMap<>(map);
        }
    }
}

Related

  1. newHashMap(Object... kv)
  2. newHashMap(T key, U value)
  3. newHashMapWithCapacity(int expectedSize, float loadFactor)
  4. toHashMap( Entry[] entries)
  5. toHashMap(ArrayList list, int beginId)
  6. toHashMapStrObj(Object object)