The following is my code.

When the test case is [], the output should return [], right?

But the expected answer is: Line 12: java.lang.ArithmeticException: / by zero? Why???

```
public class Solution {
public void rotate(int[] nums, int k) {
if(k==0||nums.length==0) return;
k = k%(nums.length);
swap(nums, nums.length-k, nums.length);
swap(nums, 0, nums.length-k);
swap(nums, 0, nums.length);
}
public void swap(int[] arr, int i, int j){
while(i<j){
int tmp = arr[i];
arr[i++] = arr[--j];
arr[j] = tmp;
}
}
}
```