title: Convert ArrayList to Array throws java.lang.ArrayStoreException
body: <p>i have a method <code>convertToArray()</code> which converts an <code>ArrayList</code> to an array. I want to call this method every time an element is added to the <code>ArrayList</code>.</p>
  
  <pre><code>public class Table extends ArrayList&lt;Row&gt;
  {
  public String appArray[]; //Array of single applicant details
  public String tableArray[][]; //Array of every applicant
  /**
   * Constructor for objects of class Table
   */
  public Table()
  {
  }
  
  public void addApplicant(Row app)
  {
      add(app);
      convertToArray();
  }
  
  public void convertToArray()
  {
      int x = size();
      appArray=toArray(new String[x]);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>When i call the <code>addApplication(Row app)</code> method I get the error: <code>java.lang.ArrayStoreException</code></p>
  
  <p>So I changed my <code>addApplicant()</code> method to:</p>
  
  <pre><code> public void addApplicant(Row app)
   {
      add(app);
      if (size() != 0)
      convertToArray();
  }
  </code></pre>
  
  <p>I get the same error message. Any ideas why? I figured if it checks the <code>ArrayList</code> has elements before converting it the error should not be thrown?</p>
  
  <p>I can provide the full error if needed</p>