title: java 8 stream : Use map to change last element in a List
body: <p>I have the following code: </p>
  
  <pre><code>List&lt;String&gt; list= Arrays.asList("a","b","c");
  list.stream()
      .map(x-&gt;{
          //if(isLast()) return "last";
          return x;
      })
      .forEach(System.out::println);
  </code></pre>
  
  <p>I want to change the last item in the list with "last" so the program will return something like this</p>
  
  <pre><code>a
  b
  last
  </code></pre>
  
  <p><strong>NOTE</strong>: I know I can do this very easy without streams, but I'm interested if this can be achieved with streams.</p>
  
  <p><strong>NOTE2</strong>: I provided a simple example, so I can easily understand the stream concept</p>