代码:
public class Solution { public void moveZeroes(int[] nums) { int i = 0, j = 0; while(j<nums.length){ while(nums[j] == 0){ if(j != nums.length - 1) j++; else break; } if(j>i) nums[i] = nums[j]; i++; j++; } for(int k = i; k < j; k++) nums[k] = 0; } }