title: What is the most efficient method to remove null values within an array.
body: <p>I am curious what the most efficient method of removing null values in arrays is. Here is my current null(0) removal method.</p>
  
  <pre><code>public static int[] removeNull(int[] array){
          int j = 0;
          for( int i=0;  i&lt;array.length;  i++ )
          {
              if (array[i] != 0)
                  array[j++] = array[i];
          }
          int [] newArray = new int[j];
          System.arraycopy( array, 0, newArray, 0, j );
          return newArray;
  }
  </code></pre>
  
  <p>What is this method performance? I was expecting it to be n.</p>