Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static <K, V> Map<K, V> map(List<K> keys, List<V> values) {
        return map(keys, values, true);
    }

    public static <K, V> Map<K, V> map(List<K> keys, List<V> values, boolean ignoreNull) {
        Map<K, V> ret = new LinkedHashMap<K, V>();
        for (int i = 0; i < keys.size(); i++) {
            V v = values.get(i);
            if (ignoreNull && v == null) {
                continue;
            }
            ret.put(keys.get(i), values.get(i));
        }
        return ret;
    }
}