First post ever here. Short story, I had to make a tetris game in Java, it was working fine but it had some problems in the optimization aspect (I only started programming this semester).
When I was discussing the game with the teacher he pointed at me for having unnecessary code when a line was full and I had to delete/shift the lines.
I don't have the exact code at the moment but it was something along these lines:
public static int [][] trueBoard = new int [DIM_LINES][DIM_COLS];
//**CODE TO SHIFT LINES**//
for(int line=0;line < DIM_LINES;++l) //about this, ++l or l++?
for(int cols=0;cols < DIM_COLS;++c)
trueBoard[l][c]=trueBoard[l-1][c];
The teacher said it was useless to be in 2 for and I should simply do
for(int line=0;line < DIM_LINES;++l)
trueBoard[l]=trueBoard[l-1];
But after I made that change the game bugs quite heavily. From my research it seems that doing it this way makes the array point at the same "object" (in this case an int) instead of simply copying the elements. So I'm asking if someone could explain a bit more in depth analysis and help a bit with this solution/another