title: Get last not null element of list by using Java 8
body: <p>In Java 7, if I want to get the last not null element of a list, I write something like this:</p>
  
  <pre><code>public CustomObject getLastObject(List&lt;CustomObject&gt; list) {
      for (int index = list.size() - 1; index &gt; 0; index--) {
          if (list.get(index) != null) {
              return list.get(index);
          }
      }
      // handling of case when all elements are null
      // or list is empty
      ...
  }
  </code></pre>
  
  <p>I want to write a shorter code by using lambdas or another feature of Java 8. For example, if I want to get the first not null element I can write this:</p>
  
  <pre><code>public void someMethod(List&lt;CustomObject&gt; list) {
      .....
      CustomObject object = getFirstObject(list).orElseGet(/*handle this case*/);
      .....
  }
  
  public Optional&lt;CustomObject&gt; getFirstObject(List&lt;CustomObject&gt; list) {
      return list.stream().filter(object -&gt; object != null).findFirst();
  }
  </code></pre>
  
  <p>Maybe someone know how to solve this problem?</p>