title: Convert stream of Strings to stream of Longs
body: <p>I have a <code>List&lt;String&gt;</code> that I would like converted to a <code>List&lt;Long&gt;</code>. Before Java 8, I would do this by looping through the <code>List&lt;String&gt;</code>, converting each <code>String</code> to a <code>Long</code> and adding it to the new <code>List&lt;Long&gt;</code>, as shown below.</p>
  
  <pre><code>List&lt;String&gt; strings = /* get list of strings */;
  List&lt;Long&gt; longs = new ArrayList&lt;&gt;();
  for (final String string : strings) {
      longs.add(Long.valueOf(string));
  }
  </code></pre>
  
  <p>However, I need to do this conversion using Java 8 streams, as the conversion is part of a larger stream operation. I have the <code>List&lt;String&gt;</code> as a stream, as if I had done <code>strings.stream()</code>. So, how could I perform this conversion, similar to something like this.</p>
  
  <pre><code>List&lt;String&gt; strings = /* get list of strings */;
  List&lt;Long&gt; longs = strings.stream().map(/*convert to long*/).collect(Collectors.toList());
  </code></pre>