title: Multiple null checks in Java 8
body: <p>I have the below code which is bit ugly for multiple null checks.</p>
  
  <pre><code>String s = null;
  
  if (str1 != null) {
      s = str1;
  } else if (str2 != null) {
      s = str2;
  } else if (str3 != null) {
      s = str3;
  } else {
      s = str4;
  }
  </code></pre>
  
  <p>So I tried using <code>Optional.ofNullable</code> like below, but its still difficult to understand if someone reads my code. what  is the best approach to do that in Java 8.  </p>
  
  <pre><code>String s = Optional.ofNullable(str1)
                     .orElse(Optional.ofNullable(str2)
                                     .orElse(Optional.ofNullable(str3)
                                                     .orElse(str4)));
  </code></pre>
  
  <p>In Java 9, we can use <code>Optional.ofNullable</code>with <code>OR</code>, But in Java8 is there any other approach ?</p>