Using removeif on a hashmap
<p>I am trying to remove entries from a Hashmap, if i have already used them. Sadly, I'm not familier with Java 8 lambda expressions, so I'm not sure how to remove the entries correctly. Could somebody help me or explain what I have to do?</p>

<p>Here is the way I've tried doing it:</p>

<pre><code>ArrayList&lt;Integer&gt; range10 = new ArrayList&lt;Integer&gt;();
    ArrayList&lt;Integer&gt; range15 = new ArrayList&lt;Integer&gt;();
    ArrayList&lt;Integer&gt; rangeMax = new ArrayList&lt;Integer&gt;();

for (int age = 16; age &lt;= 100; age++){
        for (Entry&lt;Integer, Partner&gt; entry : dbMap.entrySet()){
            int key = entry.getKey();
            Partner person = entry.getValue();
            if (person.getAge() == alter &amp;&amp; person.getAgeRange() == 10){
                range10.add(key);
                entry.setValue(null);
            }
            else if (person.getAge() == alter &amp;&amp; person.getAgeRange() == 15){
                range15.add(key);
                entry.setValue(null);
                }
            else if (person.getAge() == age){
                rangeMax.add(key);
                entry.setValue(null);
                }
            dbMap.entrySet().removeIf(entries-&gt;entries.getValue().equals(null));

        }
</code></pre>

<p>And I get a <code>java.lang.NullPointerException</code> for it. I don't think this is a duplicate to asking what a NullPointerexception is, since I'm primarily asking how to use the removeif-function.</p>