Add Not Null Key And Value to a Map - Java java.util

Java examples for java.util:Map Entry

Description

Add Not Null Key And Value to a Map

Demo Code


//package com.java2s;

import java.util.Map;

public class Main {
    public static <K, V> boolean putMapNotNullKeyAndValue(Map<K, V> map,
            K key, V value) {/*from   w w w .ja  va2 s.  c o m*/
        if (map == null || key == null || value == null) {
            return false;
        }

        map.put(key, value);
        return true;
    }
}

Related Tutorials