3 ways to flatten a list of lists. Is there a reason to prefer one of them?
<p>Assume we have a list as follows. <code>CoreResult</code> has a field of type <code>List&lt;Double&gt;</code>.</p>

<pre><code>final List&lt;CoreResult&gt; list = new LinkedList&lt;&gt;(SOME_DATA);
</code></pre>

<p>The objective is to flatten the list after extracting that specific field from each <code>CoreResult</code> object.
Here are 3 possible options. Is any one of them preferable to the others?</p>

<p><strong>Option 1</strong>: extract a field via <code>map()</code> and flatten inside collector</p>

<pre><code>final List&lt;Double&gt; A = list.stream().map(CoreResult::getField)
            .collect(ArrayList::new, ArrayList::addAll, ArrayList::addAll);
</code></pre>

<p><strong>Option 2</strong>: extract a field via <code>map()</code>, flatten via <code>flatMap()</code>, simple collector</p>

<pre><code>final List&lt;Double&gt; B = list.stream().map(CoreResult::getField)
            .flatMap(Collection::stream).collect(Collectors.toList());
</code></pre>

<p><strong>Option 3</strong>: extract a field and flatten in one go via <code>flatMap()</code>, simple collector</p>

<pre><code>final List&lt;Double&gt; C = list.stream().flatMap(
             x -&gt; x.getField().stream()).collect(Collectors.toList());
</code></pre>

<p>Would the answer be different if there was no need to extract any field from CoreResult, and instead one wanted to simply flatten a <code>List&lt;List&lt;Double&gt;&gt;</code>?</p>