title: Java - TicTacToe game with two-dimensional arrays
body: <p>I'm trying to create a Tic Tac Toe game where, instead of starting with nothing on the board, the user actually inputs the board and the program tells him which side won, or if there's a draw. Using two dimensional arrays, I thought of having the user input being an individual line and then taking the characters and putting them in the array. The program would determine where to put the characters inputted according to how many times it went through the while loop. But, I bumped into multiple problems : The program doesn't only take 3 inputs, it takes more, and the error message that should be brought up when the length of the input isn't 3 won't show sometimes. Finally, when the array DOES show up, it brings up numbers instead of x's and o's.</p>
  
  <pre><code>import java.util.*;
  public class TicTacToe {
      public static void PrintingRow(int[] row) { // we define how we want the board to be displayed (i.e. no brackets and no commas.)
  
          for (int i : row) {
              System.out.print(i); }
          System.out.println();
          } 
  
      public static void main(String[] args) {
          int TicTac[][]= new int[3][3];
  
          System.out.println("Enter the Tic Tac Toe board you want to see, one line at a time.");
          Scanner scanner = new Scanner(System.in);
  
          int loop = 0;
  
              while (loop != 3) { // we count the loops so that there's only 3 different lines
                  String ticTacLine = scanner.nextLine();
                  if (ticTacLine.length() != 3) {  // I try to define the array by a series of inputs that go in the while loop.
                      System.out.println("Tic-tac-toe plays in a 3×3 grid. This means if you want to input a line, you would want to input 3 characters, no more, no less.");
  
                  } else {
                      char uno = ticTacLine.charAt(0);
                      char dos = ticTacLine.charAt(1);
                      char tres = ticTacLine.charAt(2);
  
                      if ((uno != 'x' &amp;&amp; uno != 'o') || (dos != 'x' &amp;&amp; dos != 'o') || (tres != 'x' &amp;&amp; tres != 'o')) {
                          System.out.println("Have you never played Tic Tac Toe before ? It's okay if you haven't, but just FYI, it plays with x's and o's.");
                          break;
                      } else { 
                          if (loop == 0) {
                              TicTac[0][0] = uno;
                              TicTac[0][1] = dos;
                              TicTac[0][2] = tres;
                              loop = ++loop;
                              ticTacLine = scanner.nextLine();
                          } else if (loop == 1) {
                              TicTac[1][0] = uno;
                              TicTac[1][1] = dos;
                              TicTac[1][2] = tres;
                              loop = ++loop;
                              ticTacLine = scanner.nextLine();
                          } else if (loop == 2) {
                              TicTac[2][0] = uno;
                              TicTac[2][1] = dos;
                              TicTac[2][2] = tres;
                              loop = ++loop;
                              ticTacLine = scanner.nextLine();
                              }
                          }
                      }
                  } 
              if (loop == 3) {
                  for(int[] row : TicTac) {
                      PrintingRow(row);
                      } }
          // Here we want to check what character won (x's or o's)
  
  
              }
          }
  </code></pre>