How to handle NullpointerException in this case
<p>This is my for loop function inside the servlet </p>

<p>Here i have a question .
The Data will be passed from the USER Interface to this .</p>

<p>In some conditions , some information (For example  symbol or side ) may not be passed , then in those conditions , i am getting NullPointreException as null would be supplied to it .</p>

<pre><code>List&lt;Bag&gt; bags = new ArrayList&lt;Bag&gt;(bagdata.length);

for (FormBeanData ld : data) {
    Bag bag = new Bag();
    bag.symbol = ld.getSymbol();
    bag.side = ld.getSide();
    bags.add(bag );
}
</code></pre>

<p>Is there anyway we can handle such situations ??</p>

<p>Thank you .</p>
