How can I set a flag value in an array loop?
<p>I have an array as shown below.</p>

<p>Basically in this array, sometimes thebagdata[i].getSecurityType()  may or may not contain values in an array.</p>

<pre><code> for (int i = 0; i &lt;bagdata.length; i++) {
                if (bagdata[i].getSecurityType() != null) {
                    flag = true;
                } else {
                    flag = false;
                }

            }
</code></pre>

<p>I think that my code is overriding the flag value. How can I deal with this?</p>
