title: Return the first element of a list inside an object using Java 8
body: <p>I'm unsure how to do this,</p>
  
  <p>I have an object named <code>StudentCollection</code> which contains a list field <code>students</code>. </p>
  
  <pre><code>public class StudentCollection {
       private List&lt;Student&gt; students;
       //getter and setter
  }
  </code></pre>
  
  <p>Is there any way to get the first element of the students list ( <code>Student</code> object), by checking that <code>StudentCollection</code> and <code>students</code> are not null using <strong>Java 8 (Optional/Stream)</strong>.</p>
  
  <p>I knew this is a simple task with pre java8 code.! </p>