title: java.lang.ArrayStoreException at java.lang.System.arraycopy(Native Method) at java.util.ArrayList.toArray(Unknown Source) at Hai.main(Hai.java:20)
body: <p>I am getting the following error when executing the code below...</p>
  
  <p>I am trying to convert the list of Object arrays to a BigDecimal array using the toArray()
  method of the List collection..</p>
  
  <p>When I simply give fileFormatObj.toArray() it is working fine, but when I give like in the code below I am getting the error....</p>
  
  <pre><code>public static void main(String[] args) 
  {
      List&lt;BigDecimal&gt; objList = new ArrayList&lt;BigDecimal&gt;();
      List&lt;Object[]&gt; fileFormatObj = new ArrayList&lt;Object[]&gt;();
      final Object[] array1 = new Object[1];
      array1[0] = new BigDecimal(BigInteger.ONE);
      fileFormatObj.add(array1);
      if (fileFormatObj != null) 
      {
          //Error here java.lang.System.arraycopy    
          final BigDecimal[] arr = fileFormatObj
              .toArray(new BigDecimal[fileFormatObj.size()]);
  
          objList.addAll(Arrays.asList(arr));
          for (final BigDecimal object : arr) {
              System.out.println("TEST--&gt;" + object.intValue());
          }
      }
  }
  </code></pre>