```
public void rotate(int[][] matrix) {
int l = matrix.length;
int[][] visit = new int[l][l];
for(int i = 0; i < l; i++){
for(int j = 0; j < l; j++){
if(visit[i][j] == 0){
int temp = matrix[i][j];
matrix[i][j] = matrix[j][l-i-1];
matrix[j][l-i-1] = temp;
visit[i][j] = 1;
visit[j][l-i-1] = 1;
}
}
}
}
```