title: What is the breakdown for Java's lambda syntax?
body: <p>Please explain the syntax for Java 8's lambda methods.</p>
  
  <p>There are a lot of explanations out there for <em>what</em> lambda functions are, but I can't find a thorough explanation of the syntax, and I am finding it very difficult to learn to replicate the syntax correctly because I don't understand <em>why</em> they're written as they are.</p>
  
  <p>Here's a common case that I run into, courtesy NetBeans:</p>
  
  <pre><code>public static void main(String[] args) {
      SwingUtilities.invokeLater(() -&gt; {
          new MainAppJFrame();
      });
  }
  </code></pre>
  
  <p>So somehow, the following lambda expression is resolving into an anonymous <code>Runnable</code> object's run() method:</p>
  
  <pre><code>() -&gt; {
      // do stuff
  }
  </code></pre>
  
  <p>The <code>-&gt;</code> is the lambda syntax proper, right? And the curly braces are simply containing the anonymous method code. Are the parentheses an empty argument, because in this case we're creating a <code>Runnable.run()</code> method?</p>
  
  <p>This is all rather unclear to me. I assume the compiler knows to instantiate an anonymous <code>Runnable</code> based on the type expected by the <code>SwingUtilities.invokeLater(Runnable)</code> method? What would happen if there were two <code>SwingUtilities.invokeLater</code> methods which differ only in parameter list? Obviously there aren't in this specific case, but it's possible elsewhere:</p>
  
  <pre><code>interface ExampleLambdaConsumer {
      public void doSomething(Runnable r);
      public void doSomething(java.lang.reflect.Method m);
  }
  
  class C implements ExampleLambdaConsumer {
      // implementations for doSomething methods here
  
      public static void main(String[] args) {
          doSomething(() -&gt; {
              // lambda method body here
          }
      }
  }
  </code></pre>