Есть ли проблема с тем, как я реализую цикл for?Я пытаюсь сдвинуть вправо каждый элемент в каждой строке.
import java.util.Arrays;
import java.util.Scanner;
public class rotateRight {
public static void main(String[] args) {
int[][] myList = {{1, 2, 3}, {-1, -2, -3, -4, -5}};
int row = 0;
int col = 0;
for (row = 0; row <= myList.length-1;row++) {
for (col = 0; col < myList[row].length-2; col++) {
int temp = myList[row][col];
myList[row][col]=myList[row][col+1];
myList[row][col+1] = temp;
// wrapp around
int last= myList[row][myList.length-1];
myList[row][0]=last;
}
}
}
}