I am curious what the most efficient method of removing null values in arrays is. Here is my current null(0) removal method.
public static int[] removeNull(int[] array){
int j = 0;
for( int i=0; i<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;
}
What is this method performance? I was expecting it to be n.