How would i rotate a string array in java for a tetris game i am making. For example, the string array
[
"JJJJ",
"KKKK",
"UUUU"
]
would become
[
"UKJ",
"UKJ",
"UKJ",
"UKJ"
]
I can do it with a char matrix using this code
public char[][] rotate(char[][] toRotate)
{
char[][] returnChar = new char[toRotate[0].length][toRotate.length];
for(int rows = 0; rows<toRotate.length; rows++)
{
for(int cols = 0; cols<toRotate[0].length; cols++)
{
returnChar[cols][toRotate.length-1-rows]=toRotate[rows][cols];
}
}
return returnChar;
}