title: Java 8 stream list collector memory allocation speed vs loop with preallocation
body: <p>I am wondering how Java 8 streams handle memory allocation if the terminal operation is a list collector.</p>
  
  <p>Consider for example </p>
  
  <pre><code>List&lt;Integer&gt; result = myList.stream().map(doWhatever).collect(Collectors.toList());
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>List&lt;Integer&gt; result = new ArrayList&lt;&gt;(myList.size());
  for(String s : myList) {
    result.add(doWhatever.apply(s));
  }
  </code></pre>
  
  <p>In case of using a stream, it is unknown how large the list will grow, which means there must be some kind of reallocation. Is this assumption true?</p>
  
  <p>Is the type of the resulting list some kind of linked list and gives therefore slower access to elements than the ArrayList?</p>
  
  <p>Should I not use streams with list collectors if I know the size of the resulting list from the beginning on?</p>