title: Java 8: modify specific element in the stream by using lambda expressions
body: <p>I need to modify a list on int as it follows:</p>
  
  <ul>
  <li>Every element == 10 needs to be doubled</li>
  </ul>
  
  <p>Here is my attempt:</p>
  
  <pre class="lang-js prettyprint-override"><code>list.stream()
              .filter(val -&gt; val.getValue() == 10)
              .map(val -&gt; {
                  val.doubleValue();
                  return val;
              })
              .forEach(System.out::println);
  </code></pre>
  
  
  
  <p>The problem is that I'm filtering the elements, while I would like to keep them all and just modify the ones == 0.</p>
  
  <p>EDIT: the list is composed of elements of <code>MyType</code>, defined as it follows:</p>
  
  <pre class="lang-js prettyprint-override"><code>public class MyType {
  
      private int val;
  
      public MyType(int v){
          this.val = v;
      }
  
      public void doubleVal(){
          val*val;
      }
  
      public int getValue(){
          return val;
      }
  }
  </code></pre>
  
  
  
  <p>Any suggestion?</p>