title: How to return null when condition is not found?
body: <p>I'm trying to get a return null when my method does not find what its looking for. The method is looking for the most recent submission before the deadline (the parameter). Can someone help me how to get this when there is no submission before the parameter date. Thanks!</p>
  
  <pre><code>    // students is a LinkedList
  
      @Override
      public Submission getSubmissionBefore(String unikey, Date deadline) {
          // TODO Implement this, ideally in better than O(n)
  
          if (unikey == null || deadline == null) {
              throw new IllegalArgumentException("Unikey or deadline was null");
          }
  
          Date tempDate = null;
          int k = -1;
  
          for (int i = 0; i &lt; this.students.size(); i++) {
              if (students.get(i).getUnikey().equals(unikey)) {
                  if (tempDate == null) {
                      tempDate = students.get(i).getTime();
                      k = i;
                  } else if (students.get(i).getTime().before(deadline) &amp;&amp; students.get(i).getTime().after(tempDate)) {
                      k = i;
                  }
              }
          }
  
          return students.get(k);
      }
  </code></pre>