public static int[] move(int [] array) { //自右向左扫描,将所有非零元素紧凑到右侧 int low,high; for(low = array.length-1,high=low ; low>=0;low--) if(array[low]!=0) { array[high] = array[low]; high -- ;//更新紧凑序列的最左侧元素 } //将余下所有元素全部置为0 for(;high>=0 ; high--) array[high] = 0; return array; }