# LC283 - Move Zeroes
# 双指针
```java=
class Solution {
public void moveZeroes(int[] nums) {
// sanity check
if (nums == null || nums.length == 0) {
return;
}
int length = nums.length;
// the elements from 0 to i but not include i are not 0
int i = 0, j = 0;
while (j < length) {
if (nums[j] != 0) {
swap(nums, i++, j);
}
j++;
}
}
private void swap(int[] nums, int i, int j) {
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
}
```