I'm practicing making the game Battleship. I made the game grid for the player here, and tried to copy the grid for the computer player. However, when I change the AI's grid, it changes the player's grid. I read this is because they are referenced together, not individual copies.
static String[] Row1 = new String[] {" ", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
static String[] Row2 = new String[] {"A", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"};
static String[] Row3 = new String[] {"B", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"};
static String[] Row4 = new String[] {"C", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"};
static String[] Row5 = new String[] {"D", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"};
static String[] Row6 = new String[] {"E", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"};
static String[] Row7 = new String[] {"F", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"};
static String[] Row8 = new String[] {"G", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"};
static String[] Row9 = new String[] {"H", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"};
static String[] Row10 = new String[] {"I", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"};
static String[] Row11 = new String[] {"J", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"};
static String[][] playerGrid = {Row1,Row2,Row3,Row4,Row5,Row6,Row7,Row8,Row9,Row10,Row11};
static String[][] aiGrid = playerGrid;
I read about using clone(), but I'm not sure where that goes in the code.
I also tried
static String[][] aiGrid = new String[][](playerGrid.getText());
but I got an error stating I was trying to store a String [] into a String[][]
Any advice?