public static void rotate(int[][] matrix) {
		// diagonal
		// x1+y2 = n, x2+y1=n
		int n = matrix.length - 1;
		for (int i = 0; i <= n; i++) {
			// note about the value of j.
			for (int j = 0; j <= n - i; j++) {
				int temp = matrix[i][j];
				matrix[i][j] = matrix[n - j][n - i];
				matrix[n - j][n - i] = temp;
			}
		}
		n = matrix.length;
		for (int i = 0; i < n / 2; i++) {
			for (int j = 0; j < n; j++) {
				int temp = matrix[i][j];
				matrix[i][j] = matrix[n - 1 - i][j];
				matrix[n - 1 - i][j] = temp;
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				System.out.print(matrix[i][j] + " ");
			}
			System.out.println();
		}

	}