title: Remove elements from 2D array
body: <p>I want to remove elements that are in <code>routedClients</code> from <code>array</code>, so I converted it to an <code>ArrayList</code>, then used <code>remove</code>, finally I converted it back to <code>double[][]</code> array. But when I execute it, it gives me this message about this line:  </p>
  
  <pre><code>double[][] remainingStockout = (double[][]) stockout.toArray();
  </code></pre>
  
  <p>The error is:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [[Ljava.lang.Double;</p>
  </blockquote>
  
  <p>Any help would be really appreciated. :)</p>
  
  <pre><code>public double[][] removeSite(double[][] array) {
  
      List&lt;double[]&gt; stockout = new ArrayList&lt;double[]&gt;(Arrays.asList(array));
  
      for (int i = 0; i &lt; array.length; i++) {
          for (int j = 0; j &lt; routedClients.size(); j++) {
  
              if (array[i][0] == routedClients.get(j)) {
  
                  stockout.remove(i);
              }
          }
      }
  
      double[][] remainingStockout = (double[][]) stockout.toArray();
  
      return remainingStockout;
  
  }
  </code></pre>