I want to rotate k top element of array for example:

k = 2

array before rotate --> 3 , 4 , 2

array after rotate ---> 3 , 2 , 4

```
int[] temp = new int[k];
for (int i = 0; i < k; i++) {
if(this.stack[i]!= null){
temp[i] = this.pop();
} else
i--;
}
for (int i = 0 ; i <k ; i++) {
this.push(temp[i]);
}
```

i want to implement it by stack

can any one help me to optimize it ?