title: Optional for finding if list contains object at index
body: <p>I am exploring the use of Optionals.
  Below I have a case where I would like to instantiate a new object (here Data object) if a list (containing Data Objects) doesn't have an object at a specific index.
  Is this possible to achieve with Optional?</p>
  
  <pre><code>List&lt;Data&gt; dataList = new ArrayList&lt;&gt;();
  for (int i = 0; i &lt; dataList.size();i++) {
      Data data = Optional.ofNullable(dataList.get(i)).orElse(new Data()); // this will throw an error of index out of bounds
  }
  </code></pre>