title: Random position in string array? Java
body: <p>Working on building a tic tac toe game. I'm trying to use as simple of methods as possible. I'm currently working on getting the cpu to randomly choose a spot in the array to place the "O" at. How do I go about doing this? This is what I have so far.</p>
  
  <pre><code>import java.util.Scanner;
  import java.util.Random;
  public class Player
  
  {
      String player = "X";
      String cpu = "O";
      //private int[][] theBoard= new int [3][3] ;
  
      private String[][] theBoard=  {{" "," "," "}, {" "," "," "}, {" ", " "," "}};;
      Random cpuInput = new Random(); 
  
      private Board board1;
      public static Scanner scan = new Scanner(System.in);
  
  public Player(Board board, String inBoard )
      {
          theBoard = theBoard;
  
      }
  
      public void computerMove()
      {
          String spacing = " ";
          for (int i = 0; i &lt; theBoard.length; i++)
          {
              for (int j = 0; j &lt; theBoard[i].length; j++)
              {
  
                  //int random = cpuInput.nextInt(theBoard[i][j]);
                  theBoard[2][2] = (cpu); //STUCK HERE!                
              }
          }
  }
  </code></pre>