Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

import java.util.Map;

public class Main {
    /**
     * Delete all the keys with null values of the map received
     * @param map Map<String, Object> map to clean
     */
    public static void cleanMapNullValues(Map<String, Object> map) {

        //check map is null
        if (map == null) {
            return;
        }

        for (String key : new ArrayList<>(map.keySet())) {
            if (map.get(key) == null) {
                map.remove(key);
            }
        }

    }
}