Add Not Null Key to Map - Java java.util

Java examples for java.util:Map Entry

Description

Add Not Null Key to Map

Demo Code


//package com.java2s;

import java.util.Map;

public class Main {
    public static <K, V> boolean putMapNotNullKey(Map<K, V> map, K key,
            V value) {//from   w  ww .j  a va  2 s  .c o  m
        if (map == null || key == null) {
            return false;
        }

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

Related Tutorials