title: Java 8 lambda: given a list, remove all elements except for the first element, without creating a new list
body: <p>As the title says, I would like to use Java 8's streams &amp; lambda expressions in order to remove all the elements but the first one from a list. So that would change the original list to practically a singleton.</p>
  
  <p>Usually I see lambda expression like this (assuming <code>list</code> is <code>ArrayList&lt;Sting&gt;</code>):</p>
  
  <pre><code>list.removeIf(string -&gt; string.endsWith("suffix"));
  </code></pre>
  
  <p>So the condition is on the element but not on the index of the element. Is it possible with Java 8's API to write a predicate on the index? Something like this:</p>
  
  <pre><code>list.removeIf(index -&gt; index &gt; 0);
  </code></pre>
  
  <p>When I try something like this:</p>
  
  <pre><code>list.stream().limit(1);
  </code></pre>
  
  <p>the problem is, that it does not change the original list. So I have to collect the elements on the stream into a new list.</p>