title: How to use non final variable in Java 8 Lambdas
body: <p>How can I use non-final variable in Java 8 lambda. It throws compilation error saying 'Local variable date defined in an enclosing scope must be final or effectively final'</p>
  
  <p>I actually want to achieve the following</p>
  
  <pre><code>public Integer getTotal(Date date1, Date date2) {
      if(date2 == null || a few more conditions) {
          date2 = someOtherDate;
      }
      return someList.stream().filter(filter based on date1 and date2).map(Mapping Function).reduce(Addition);
  }
  </code></pre>
  
  <p>How do I achieve this? It throws comilation error for date2.
  Thanks,</p>