title: Java List, Counting non-zero attributes of Object, by group of 3
body: <p>I have a <code>ArrayList&lt;Fileline&gt;</code> and inside <code>Fileline</code> a function </p>
  
  <pre><code>public Double getValue() {
      ...
      doing stuff
      ...
      return value;
  }
  </code></pre>
  
  <p>What I'm trying to do is return the <code>count</code> of any non-zero <code>getValue()</code> of a group of 3 filelines. </p>
  
  <p>Let's say I have <code>List&lt;Fileline&gt; filelines</code> of <code>filelines.size() = 12</code> and their respective <code>getValue()</code> are <code>0,0,0, 0,1,2, 0,3,0, 4,5,5</code> then the <code>result</code> I'd like would be 3, all are valid expect the first group.</p>
  
  <p>If it was group of 1 fileline I could <code>filter</code> and <code>count</code> like this :</p>
  
  <pre><code>long resultCount = filelines.stream().filter(x -&gt; x.getValue() &gt; 0).count();
  </code></pre>
  
  <p>, but the fact that it's by group of 3 is causing me problem.</p>
  
  <p>Is the best approach to split the list into multiple 3 elements sublists or is their a more elegant way?</p>