title: Detect non-null reference in an array
body: <p>I just asked <a href="https://stackoverflow.com/questions/4729792/">a similar question</a>, but then I realized I actually need something else. Since that question already has two answers, I do not want to edit my question. So here is what I actually need:</p>
  
  <hr>
  
  <p>I want to detect whether a subrange of an array contains <em>null references only</em>. Somehow like this:</p>
  
  <pre><code>public static &lt;T&gt; boolean nullReferencesOnly
  (T[] array, int fromInclusive, int toExclusive)
  {
      for (int i = fromInclusive; i &lt; toExclusive; ++i)
      {
          if (array[i] != null) return false;
      }
      return true;
  }
  </code></pre>
  
  <p>Is there a method like this in the Java library so I don't have to manually loop over the array?</p>