Java HashMap Create newHashMap(T key, U value)

Here you can find the source of newHashMap(T key, U value)

Description

new Hash Map

License

Open Source License

Declaration

public static <T, U> Map<T, U> newHashMap(T key, U value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.HashMap;

import java.util.Map;

public class Main {
    public static <T, U> Map<T, U> newHashMap(T key, U value) {
        Map<T, U> m = new HashMap<T, U>();

        m.put(key, value);// w w  w  .java 2 s. co m

        return m;
    }

    public static <T, U> Map<T, U> newHashMap(T[] keys, U[] values) {
        Map<T, U> m = new HashMap<T, U>();

        for (int i = 0; i < keys.length; i++) {
            m.put(keys[i], values[i]);
        }

        return m;
    }
}

Related

  1. newHashMap(K[] keys, V[] values)
  2. newHashMap(K[] keys, V[] values)
  3. newHashMap(Map.Entry... entries)
  4. newHashMap(Map m)
  5. newHashMap(Object... kv)
  6. newHashMapWithCapacity(int expectedSize, float loadFactor)
  7. toHashMap( Entry[] entries)
  8. toHashMap(ArrayList list, int beginId)
  9. toHashMap(final Map map)