title: Why do lambdas work without declaration of the variable you're using in it? (Java)
body: <p>Here is an example of code that seems to be working but I don't get why:</p>
  <pre><code>public static void replaceElements(List&lt;Integer&gt; list, int operator) {
      list.replaceAll(element -&gt; element % operator);
  }
  </code></pre>
  <p>How does Java know that the variable element means an element of list? And why does the replaceAll method work although the javadoc says the argument has to be a unary operator?:</p>
  <pre><code>default void replaceAll(UnaryOperator&lt;E&gt; operator)
  </code></pre>
  <p>I tried to understand it by debugging step by step but it didn't help much. Thanks for any answers!</p>