title: Java 7 to Java 8: Steps after getting default value from hashmap and then updating underlying map if not null?
body: <p>I previously had a piece of old school code that looked like this prior to Java 8:</p>
  <pre><code>List&lt;Person&gt; databaseListOfPersons = ... //random list of Person object
  
  Map&lt;String, List&lt;Person&gt;&gt; somePersonListLookup = new HashMap&lt;&gt;();
  ...
  for (Person person: databaseListOfPersons) {
       List&lt;Person&gt; personList = somePersonListLookup.get(person.getId());
  
       if (personList == null) {
            personList = new ArrayList&lt;&gt;();
            somePersonListLookup.put(person.getId(), personList);
       }
       personList.add(person)
  }
  
  </code></pre>
  <p>The <code>getId()</code> method for the <code>Person</code> class would just return <code>A, B, or C</code> as a simple string. This block of code pretty much checked if there was an existing <code>id</code> key available, and if not then create a new entry and then add that <code>person</code> to the list of persons that was  apart of the Map. If the <code>id</code> key was already and entry, then to just add that person to the list and it would update the value to the already existing key, further increasing the list of people with the same <code>id</code> key.</p>
  <p>So I want to just update the code to Java 8 and keep up with times and I have the old code converted to this:</p>
  <pre><code>List&lt;Person&gt; personList = somePersonListLookup.computeIfAbsent(person.getId(), x -&gt; new ArrayList&lt;&gt;());
  
  personList.add(person);
  </code></pre>
  <p>My question is: <em><strong>is this proper?</strong></em> It feels weird having a list initialized and not being used and then having the <code>personList</code> add the object like previously.</p>