Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.util.Map;

import java.util.Set;
import java.util.TreeSet;

public class Main {
    public static <K, V> void addToMap(K key, V value, Map<K, Set<V>> map) {

        if (key != null && value != null)
            if (map.containsKey(key))
                map.get(key).add(value);
            else {
                Set<V> values = new TreeSet<V>();
                values.add(value);
                map.put(key, values);
            }
    }
}