title: Using parameters inside lambda expression
body: <p>I am wondering why I can use the method parameters i and j inside the lambda and where they are stored in the anonymous class. I also noticed the compiler automatically makes these parameters final. What's going on here in the background I am not aware of?</p>
  <pre><code>public class Editor {
  
      public interface Task {
          int edit();
      }
  
      static ArrayList&lt;Task&gt; tasks = new ArrayList&lt;&gt;();
  
      public static void add(int i, int j) {
          tasks.add(() -&gt; i + j);
      }
  
  
      public static void main(String[] args) {
          add(4,5);
          System.out.println(tasks.get(0).edit());
      }
  
  }
  </code></pre>