title: IndexOutofBoundsException resolution in this given scenario
body: <p>Need to figure out the best way to get rid of the following problem of <code>java.lang.IndexOutofBoundsException: Index: 1, Size: 0</code> <br /></p>
  
  <p>As seen in the code, this exception is occurring anytime the condition <br /></p>
  
  <pre><code>if(tempBean.getCustomerState.equalsIgnoreCase("MD")    
  </code></pre>
  
  <p>is false and the outer for loop continues its execution. Which makes the code look like: <br/></p>
  
  <pre><code>finalBeanOne.add(1, tempBeanOne.get(1));
  </code></pre>
  
  <p>but as finalBeanOne list never had the element at index 0 (because the if condition was false on first iteration) its throwing an <code>IndexOutofBoundsException</code>. What is the best way to fix this scenario? <br /></p>
  
  <pre><code>ArrayList&lt;BeanOne&gt; finalBeanOne = new ArrayList&lt;BeanOne&gt;();
  
  ArrayList&lt;BeanOne&gt; tempBeanOne = (cast) DAO.getBeanOneList();
  
     for(int i=0; i&lt; tempBeanOne.size; i++ ) {
  
        if(tempBeanOne.getCustomerState.equalsIgnoreCase("MD") {
  
          finalBeanOne.add(i, tempBeanOne.get(i));
        }
  
  
    }
  </code></pre>