title: How can I swap places of strings in a 2d string array
body: <p>I have homework to make a custom version of chess which is 6x6 and the pieces move in a specific way. But for now I am trying to figure out how to select a piece and then place it in another location inside the 2d array I have set up and swap the places of the characters. For now I have:</p>
  
  <pre><code>public class Chess {
  
      static final int rows = 7;
      static final int columns = 7;
  
      public static void main(String[] args) {
          String[][] board = new String[rows][columns];
          fillBoard(board);
          enterMove();
      }
      public static void fillBoard(String[][] board){
          for (int row = 0; row &lt; 7; row++) {
              for (int col = 0; col &lt; 7; col++) {
                  board[row][col] = " X ";
                  outerShell(board);
                  pawns(board);
                  System.out.print(board[row][col]);
              }
              System.out.println();
          }
      }
      public static void outerShell(String[][] board){
          board[0][0] = "   ";
          board[0][1] = " A ";
          board[0][2] = " B ";
          board[0][3] = " C ";
          board[0][4] = " D ";
          board[0][5] = " E ";
          board[0][6] = " F ";
          board[1][0] = " 6 ";
          board[2][0] = " 5 ";
          board[3][0] = " 4 ";
          board[4][0] = " 3 ";
          board[5][0] = " 2 ";
          board[6][0] = " 1 ";
      }
      public static void pawns(String[][] board){
          //whitePawns
          board[1][1] = "wDw";
          board[1][2] = " wD";
          board[1][3] = " wQ";
          board[1][4] = " wK";
          board[1][5] = " wM";
          board[1][6] = " wDw ";
          //blackPawns
          board[6][1] = "bDw";
          board[6][2] = " bM";
          board[6][3] = " bK";
          board[6][4] = " bQ";
          board[6][5] = " bD";
          board[6][6] = " bDw";
      }
      public static void enterMove(){
          System.out.println("");
          System.out.println("Select the piece you want to move(Example a1) if you want to quit enter: q");
          Scanner gameInput  = new Scanner(System.in);
          String pieceSelect = gameInput.nextLine();
          if(pieceSelect.equals("q")){
              System.exit(0);
          }
          switch (pieceSelect){
              case "a1": 
  
          }
          System.out.println(" ");
          System.out.println("Now select a finishing position for the piece to move to");
          String piecePlace = gameInput.nextLine();
          switch (piecePlace){
              case "a2": 
          }
      }
  }
  </code></pre>
  
  <p>In the <code>enterMove()</code> section, I am trying to do it with <code>switch</code> but have no idea how to swap two positions in the array. I am not dead set on using <code>switch</code> because I am not sure if it is possible at all. If someone can make a version of this code where by entering the specific coordinates(like a1) selects <code>bDw</code> then entering another coordinate and swapping <code>bDw</code> with the <code>X</code> i am using as an indicator for an empty space and if possible to explain it i'd be grateful.</p>