```
public void rotate(int[][] matrix) {
if (matrix == null) {
return;
}
int row = matrix.length;
int col = matrix.length;
//step 1:switch column
int low =0,high = col-1;
while(low < high){
int[] temp = matrix[low];
matrix[low] = matrix[high];
matrix[high] = temp;
low++;
high--;
}
//step 2:对称元素交换
for(int i=0; i<row; i++){
for(int j=0; j<i; j++){
int temp = matrix[i][j];
matrix[i][j] = matrix[j][i];
matrix[j][i] = temp;
}
}
}
```