Java Map Create createMap(K[] keys, V[] values)

Here you can find the source of createMap(K[] keys, V[] values)

Description

create Map

License

Apache License

Declaration

public static <K, V> Map<K, V> createMap(K[] keys, V[] values) 

Method Source Code

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

import java.util.HashMap;
import java.util.Map;

public class Main {
    public static <K, V> Map<K, V> createMap(K[] keys, V[] values) {
        assert keys.length == values.length : "Lengths of keys and values should be the same";
        Map<K, V> res = new HashMap<>(keys.length);
        for (int i = 0; i < keys.length; i++)
            res.put(keys[i], values[i]);
        return res;
    }/*from w w  w.  j a  va2 s .  c  o  m*/
}

Related

  1. createMap()
  2. createMap(boolean full)
  3. createMap(int len)
  4. createMap(Iterable> entries)
  5. createMap(K k1, V v1)
  6. createMap(List keys, List values)
  7. createMap(List keys, List values)
  8. createMap(Map map)
  9. createMap(Object keys[], Object values[])

  10. HOME | Copyright © www.java2s.com 2016