Find index in array that does not have a null value
<p>I have an array called e, this array contains objects, but not on every index. So I'm using a for-loop to find the first index in the array that contains an object. I do this by looking for values that is not null. If I find it, I save the index in a variable called index and break out of the loop. If no index that does not have a null values was found, I want to return from the method. Else, I want to continue and use the variable index that contains an index of the array.</p>

<pre><code>int index;

for (int i = 0; i &lt; e.length; i++) {
    if (e[i] != null) {
        index = i;
        break;
    }
}

// if index did not get any value inside the for-loop, return

// And here I use the index that was found using the for-loop
</code></pre>

<p>How can I check if the variable index got a new index from the for-loop?</p>

<p>Thanks!</p>
