title: Java Optional and orElse
body: <p>I'm new to the Java optionals but I see this code written by another developer and I don't get it:</p>
  
  <pre><code>String t = null;
  Optional.ofNullable("notnull")
      .orElse(
          Optional.ofNullable(t).orElseThrow(() -&gt; new Exception("MyException"))
      );
  </code></pre>
  
  <p>Why does this code throw the exception? Why does it even go to the "orElse" branch?</p>
  
  <p>Is this because of some weird execution order? So the first optional's value is not set before the orElse branch is evaluated?</p>