Ways to check if an ArrayList contains only null values
<p>I was looking through the code for an old Android application of mine, and I saw one thing I did to the effect of this:</p>

<pre><code>        boolean emptyArray = true;
        for (int i = 0; i &lt; array.size(); i++)
        {
            if (array.get(i) != null)
            {
                    emptyArray = false;
                    break;
            }
        }
        if (emptyArray == true)
        {
            return true;
        }
        return false;
</code></pre>

<p>There has to be a more efficient way of doing this -- but what is it?</p>

<p>emptyArray is defined as an ArrayList of Integers, which are inserted with a random number of null values (And later in the code, actual integer values).</p>

<p>Thanks!</p>
