Java Map Create createMap(List keys, List values)

Here you can find the source of createMap(List keys, List values)

  1. HOME
  2. Java
  3. M
  4. Map Create
  5. createMap(List keys, List values)

Description

create Map

License

Open Source License

Declaration

public static <A, B> Map<A, B> createMap(List<A> keys, List<B> values) 

Method Source Code

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

import java.util.HashMap;

import java.util.List;
import java.util.Map;

public class Main {
    public static <A, B> Map<A, B> createMap(List<A> keys, List<B> values) {
        Map<A, B> map = new HashMap<A, B>();
        for (int i = 0; i < keys.size(); i++) {
            if (i == values.size()) {
                break;
            }/*from ww w  .  j av a 2 s. c  om*/
            map.put(keys.get(i), values.get(i));
        }
        return map;
    }
}

Related

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

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