```
public class Solution {
public void moveZeroes(int[] nums) {
if (nums == null || nums.length == 0)
return ;
int toZeroIndex = 0;
int toNonZeroIndex = 0;
for (int i = 0 ;i < nums.length; i++)
{
if (nums[i] == 0)
{
toNonZeroIndex++;
}
else
{
int temp = nums[toZeroIndex];
nums[toZeroIndex] = nums[toNonZeroIndex];
nums[toNonZeroIndex] = temp;
// swap the value of zero and non-zero
toZeroIndex++;
toNonZeroIndex++;
}
}
}
}
```