title: Java 8- forEach method iterator behaviour
body: <p>I recently started checking new Java 8 features.</p>
  
  <p>I've come across this <code>forEach</code> iterator-which iterates over the Collection.</p>
  
  <p>Let's take I've one <code>ArrayList</code> of type <code>&lt;Integer&gt;</code> having values= {1,2,3,4,5}</p>
  
  <pre><code>list.forEach(i -&gt; System.out.println(i));
  </code></pre>
  
  <p>This statement iteates over a list and prints the values inside it.</p>
  
  <p>I'd like to know How am I going to specify that I want it to iterate over some specific values only.</p>
  
  <p>Like, I want it to start from 2nd value and iterate it till 2nd last value. or something like that- or on alternate elements.</p>
  
  <p>How am I going to do that?</p>