title: In java8, how to set the global value in the lambdas foreach block?
body: <pre><code>    public void test(){
         String x;
         List&lt;String&gt; list=Arrays.asList("a","b","c","d");
  
         list.forEach(n-&gt;{
            if(n.equals("d"))
              x="match the value";
         });
      }
  </code></pre>
  
  <p>1.Like the code above, I want to set the value of a variable beside the foreach block, can it works? </p>
  
  <p>2.And why?</p>
  
  <p>3.And the foreach iterator is in order or disorder? </p>
  
  <p>4.I think the lamdas foreach block is cool and simple for iterator,but this is really a complicated  thing to do rather than the same work in java 7 or before.</p>