Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.ArrayList;

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

public class Main {
    public static <K, E> List<E> getListInitIfEmpty(Map<K, List<E>> map, K key) {
        List<E> value = map.get(key);
        if (value == null) {
            value = new ArrayList<E>();
            map.put(key, value);
        }
        return value;
    }
}