Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Map;

public class Main {
    /**
     * Return the mapped value of the specified key k.
     * If no such key k, return the specified value v.
     * @param <K>
     * @param <V>
     * @param map
     * @param k
     * @param v the default value if no key exist.
     * @return
     */
    public static <K, V> V get(Map<K, V> map, K k, V v) {
        if (map.containsKey(k))
            return map.get(k);
        return v;
    }
}