title: Delete element from array
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/642897/removing-an-element-from-an-array-java">Removing an element from an Array (Java)</a>  </p>
  </blockquote>
  
  
  
  <p>Is there a way I can get  rid of some elements in an array.
  for instance, if i have this array</p>
  
  <pre><code>int testArray[] = {0,2,0,3,0,4,5,6}
  </code></pre>
  
  <p>Is there a "fast" way to get rid of the elements that equal 0</p>
  
  <pre><code>int resultArray[] = {2,3,4,5,6}
  </code></pre>
  
  <p>I tried this function but I got lost using Lists </p>
  
  <pre><code>public int[] getRidOfZero(int []s){
     List&lt;&gt; result=new ArrayList&lt;&gt;();
     for(int i=0; i&lt;s.length; i++){
       if(s[i]&lt;0){
         int temp = s[i];
         result.add(temp);
       }
     }
     return result.toArray(new int[]);
  }
  </code></pre>