Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static <T> T getFirst(Map<String, List<T>> multiValutMap, String key) {
        List<T> values = multiValutMap.get(key);
        if (values != null && !values.isEmpty())
            return values.get(0);
        return null;
    }

    public static <T> T getFirst(List<T> l) {
        if (l == null || l.isEmpty())
            return null;
        return l.get(0);
    }
}