title: Java 8 Stream API :How to handle null value in Map
body: <p>I have an arraylist of Map type . I want to filter out null values from the list and find max and min values. The program is working fine except for null values.</p>
  
  <pre><code>ArrayList&lt;Map&lt;String, Float&gt;&gt; elements = new ArrayList&lt;Map&lt;String, Float&gt;&gt;();
  Map&lt;String, Float&gt; element = new HashMap&lt;String, Float&gt;();
  element.put("a", (float) 1.22);
  element.put("b", (float) 1.33);
  element.put("c", (float) 1.52);
  element.put("d", (float) 1.452);
  element.put("e", (float) 1.452);
  
  Map&lt;String, Float&gt; element2 = new HashMap&lt;String, Float&gt;();
  element2.put("a", (float) 1.2332);
  element2.put("b", (float) 1.242);
  element2.put("c", (float) 1.552);
  element2.put("d", (float) 15.33);
  element2.put("e",null);
  
  elements.add(element);
  elements.add(element1);
  elements.add(element2);
  
  System.out.println("Initial Mappings are: " + elements);
  Map&lt;String, Float&gt; min = elements.stream() 
              .flatMap(m -&gt; m.entrySet().stream())
              .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, Math::min));
  
  System.out.println(min);
  </code></pre>