Thanks a lot, I used your idea to set a flag, and use another loop. It works great. I also tried putting the playing of the game into a method, but it kept giving me errors. Not sure why. My last question is actually how I would approach setting a stalemate? Would that just be another If statement under each "check for winner" 's?
Here's my new code:
package anthonytictactoe; import java.util.Scanner; public class Main { public static void main(String[] args) { int row; int col; char X; char O; boolean winner = false; boolean keepPlaying = true; Scanner in = new Scanner(System.in); System.out.println("Welcome to Tic Tac Toe!"); System.out.println("Instructions: The top row is 0, middle is 1, " + "and bottom is 2."); System.out.println("The leftmost column is 0, the middle is 1, " + "and the rightmost is 2."); do{ char[][] x = new char [3][3]; //Print the board for(row = 0; row < 3; row++){ for(col = 0; col < 3; col++){ x[row][col] = '*'; } } for(row = 0; row < 3; row++){ for(col = 0; col < 3; col++){ System.out.print(x[row][col] + " "); } System.out.println(); } do{ do{ System.out.print("Player X, what row?: "); row = in.nextInt(); System.out.print("Player X, what column?: "); col = in.nextInt(); if (x[row][col] == 'X' || x[row][col] == 'O'){ System.out.println("Space is already taken, choose again."); x[row][col] = 10;} } while (x[row][col] == 10); x[row][col] = 'X'; for (row = 0; row < 3; row++){ for(col = 0; col < 3; col++){ System.out.print(x[row][col] + " "); } System.out.println(); } //Check to see if there is a winner if (x[0][0] == 'X' && x[0][1] == 'X' && x[0][2] == 'X'){ System.out.println("Player X Wins!"); winner = true;} else if (x[1][0] == 'X' && x[1][1] == 'X' && x[1][2] == 'X'){ winner = true; System.out.println("Player X Wins!");} else if (x[2][0] == 'X' && x[2][1] == 'X' && x[2][2] == 'X'){ System.out.println("Player X Wins!"); winner = true;} else if (x[0][0] == 'X' && x[1][0] == 'X' && x[2][0] == 'X'){ System.out.println("Player X Wins!"); winner = true;} else if (x[0][1] == 'X' && x[1][1] == 'X' && x[2][1] == 'X'){ System.out.println("Player X Wins!"); winner = true;} else if (x[0][2] == 'X' && x[1][2] == 'X' && x[2][2] == 'X'){ System.out.println("Player X Wins!"); winner = true;} else if (x[0][0] == 'X' && x[1][1] == 'X' && x[2][2] == 'X'){ System.out.println("Player X Wins!"); winner = true;} else if (x[0][2] == 'X' && x[1][1] == 'X' && x[2][0] == 'X'){ System.out.println("Player X Wins!"); winner = true;} do{ System.out.print("Player O, what row?: "); row = in.nextInt(); System.out.print("Player O, what column?: "); col = in.nextInt(); if (x[row][col] == 'X' || x[row][col] == 'O'){ System.out.println("Space is already taken, choose again."); x[row][col] = 10;} } while (x[row][col] == 10); x[row][col] = 'O'; for (row = 0; row < 3; row++){ for (col = 0; col < 3; col++){ System.out.print(x[row][col] + " "); } System.out.println(); } //check for winner again if (x[0][0] == 'O' && x[0][1] == 'O' && x[0][2] == 'O'){ System.out.println("Player O Wins!"); winner = true;} else if (x[1][0] == 'O' && x[1][1] == 'O' && x[1][2] == 'O'){ System.out.println("Player O Wins!"); winner = true;} else if (x[2][0] == 'O' && x[2][1] == 'O' && x[2][2] == 'O'){ System.out.println("Player O Wins!"); winner = true;} else if (x[0][0] == 'O' && x[1][0] == 'O' && x[2][0] == 'O'){ System.out.println("Player O Wins!"); winner = true;} else if (x[0][1] == 'O' && x[1][1] == 'O' && x[2][1] == 'O'){ System.out.println("Player O Wins!"); winner = true;} else if (x[0][2] == 'O' && x[1][2] == 'O' && x[2][2] == 'O'){ System.out.println("Player O Wins!"); winner = true;} else if (x[0][0] == 'O' && x[1][1] == 'O' && x[2][2] == 'O'){ System.out.println("Player O Wins!"); winner = true;} else if (x[0][2] == 'O' && x[1][1] == 'O' && x[2][0] == 'O'){ System.out.println("Player O Wins!"); winner = true;} } while (!winner); System.out.println("Game is over! Do you want to play again?"); System.out.print("(1 for Yes, 2 for No): "); int keepplayinggame = in.nextInt(); if(keepplayinggame == 1){ keepPlaying = true; } else if(keepplayinggame == 2){ keepPlaying = false; } }while (keepPlaying); } } Override