I am making a program that acts as the net of a 2x2x2 Rubik's Cube. In this method, I plan to make an if statement for each of the 12 possible moves (up clockwise, up counterclockwise, down clockwise, etc.), but my code for turning up clockwise is not working. "move" is a string that is designated in the main class and "cube" and "temp" are both 3d char arrays containing the current state of the Rubik's Cube. "getTurn" is a method that rotates the face clockwise and takes "cube" twice (once for the cube that it will be editing and once for a temp variable that does indeed work), the int value of the face being turned, and a boolean value for which way it is being turned. It is working as intended, but when I try to create the movement of the sides of the Rubik's Cube, the temp variable for "cube", called "temp" is somehow altered as the code goes, creating incorrect outputs. I believe there is something wrong with the way that my temp is set up, because it is not behaving properly. Thank you for helping me out!
public char[][][] getMove(char[][][] cube, char[][][] temp, String move) {
//0 = u
//1 = d
//2 = l
//3 = r
//4 = f
//5 = b
if(move.equals("u")) {
cube = getTurn(cube, cube, 0, true);
cube[4][0][0] = temp[3][0][0]; cube[4][0][1] = temp[3][0][1];
cube[2][0][0] = temp[4][0][0]; cube[2][0][1] = temp[4][0][1];
cube[5][0][0] = temp[2][0][0]; cube[5][0][1] = temp[2][0][1];
cube[3][0][0] = temp[5][0][0]; cube[3][0][1] = temp[5][0][1];
EDIT:
I just got it working by removing the 3d array "temp" and replacing it with eight temp ints:
public char[][][] getMove(char[][][] cube, String move) {
//0 = u
//1 = d
//2 = l
//3 = r
//4 = f
//5 = b
if(move.equals("u")) {
cube = getTurn(cube, cube, 0, true);
char temp1 = cube[3][0][0];
char temp2 = cube[3][0][1];
char temp3 = cube[4][0][0];
char temp4 = cube[4][0][1];
char temp5 = cube[2][0][0];
char temp6 = cube[2][0][1];
char temp7 = cube[5][0][0];
char temp8 = cube[5][0][1];
cube[4][0][0] = temp1; cube[4][0][1] = temp2;
cube[2][0][0] = temp3; cube[2][0][1] = temp4;
cube[5][0][0] = temp5; cube[5][0][1] = temp6;
cube[3][0][0] = temp7; cube[3][0][1] = temp8;
If anyone knows why my previous version was not working, I would love to know.