First tictactoe game. want to see if valid or needs improvement

Just finished my first java class that taught me all the way up to oop and abstract classes. Decided to start some projects over the summer. Started with tictactoe since it sounded fairly easy to do. Lemme know if their are things that I need to improve or just general good advice so i dont make bad habits when coding. most of the code i thought of without help except when checking win conditions or if the board was full i got help from online so a lot of what i did seems kind of sloppy.

import java.util.Scanner;
import java.util.Random;
public class TicTacToe
{
    Scanner scanner = new Scanner(System.in);
    private String[][] gameBoard = {
        {" ", "|", " ", "|", " "},
        {"-", "+", "-", "+", "-"},
        {" ", "|", " ", "|", " "},
        {"-", "+", "-", "+", "-"},
        {" ", "|", " ", "|", " "}
    };
    private boolean[] space = new boolean[9];
    Random rand = new Random();
    private String name = "default player";
    private static final String CPU_NAME = "cpu";
    private String playerSymbol = "";
    private String cpuSymbol = "";
    private static String turnName = "";

    public TicTacToe (String name)
    {
        this.name = name;
    }
    public void printGameBoard ()
    {
        for (int i = 0; i < gameBoard.length; i++)
        {
            for (int j = 0; j < gameBoard[i].length; j++)
            {
                System.out.print(gameBoard[i][j]);
            }
            System.out.println();
        }
    }

    public void whosTurn(String turnName)
    {
        if (turnName.equals(name))
        {
            turnName = name;
        }
        if (turnName.equals(CPU_NAME))
        {
            turnName = CPU_NAME;
        }
    }

    public void whatSymbol()
    {
        System.out.println("What Symbol would you want? O or X?");
        String choice = scanner.nextLine();
        if(choice.toLowerCase().equals("o"))
        {
            playerSymbol = "O";
            cpuSymbol = "X";
            game();
        }
        else if (choice.toLowerCase().equals("x"))
        {
            playerSymbol = "X";
            cpuSymbol = "O";
            game();
        }
        else
        {
            System.out.println("Invalid input. try again");
            whatSymbol();
        }
    }

    public void playerTurn(int choice)
    {
        switch (choice)
        {
            case 1:
                if(turnName.equals(name))
                {
                    gameBoard[0][0] = playerSymbol;
                    break;
                }
                if(turnName.equals(CPU_NAME))
                {
                    gameBoard[0][0] = cpuSymbol;
                    break;
                }
            case 2:
                if(turnName.equals(name))
                {
                    gameBoard[0][2] = playerSymbol;
                    break;
                }
                if(turnName.equals(CPU_NAME))
                {
                    gameBoard[0][2] = cpuSymbol;
                    break;
                }
            case 3:
                if(turnName.equals(name))
                {
                    gameBoard[0][4] = playerSymbol;
                    break;
                }
                if(turnName.equals(CPU_NAME))
                {
                    gameBoard[0][4] = cpuSymbol;
                    break;
                }
            case 4:
                if(turnName.equals(name))
                {
                    gameBoard[2][0] = playerSymbol;
                    break;
                }
                if(turnName.equals(CPU_NAME))
                {
                    gameBoard[2][0] = cpuSymbol;
                    break;
                }
            case 5:
                if(turnName.equals(name))
                {
                    gameBoard[2][2] = playerSymbol;
                    break;
                }
                if(turnName.equals(CPU_NAME))
                {
                    gameBoard[2][2] = cpuSymbol;
                    break;
                }
            case 6:
                if(turnName.equals(name))
                {
                    gameBoard[2][4] = playerSymbol;
                    break;
                }
                if(turnName.equals(CPU_NAME))
                {
                    gameBoard[2][4] = cpuSymbol;
                    break;
                }
                
            case 7:
                if(turnName.equals(name))
                {
                    gameBoard[4][0] = playerSymbol;
                    break;
                }
                if(turnName.equals(CPU_NAME))
                {
                    gameBoard[4][0] = cpuSymbol;
                    break;
                }
            case 8:
                if(turnName.equals(name))
                {
                    gameBoard[4][2] = playerSymbol;
                    break;
                }
                if(turnName.equals(CPU_NAME))
                {
                    gameBoard[4][2] = cpuSymbol;
                    break;
                }
            case 9:
                if(turnName.equals(name))
                {
                    gameBoard[4][4] = playerSymbol;
                    break;
                }
                if(turnName.equals(CPU_NAME))
                {
                    gameBoard[4][4] = cpuSymbol;
                    break;
                }
            default:
                System.out.println("Invalid input. try again");
                game();
        }
    }

    public void cpuMove()
    {
        boolean run = true;
        while(run)
        {
            int choice = rand.nextInt(9) + 1;
            if (!space[choice - 1])
            {
                playerTurn(choice);
                space[choice - 1] = true;
                turnName = name;
                System.out.println("---------------------------------------------------");
                System.out.println("Cpu chose: " + choice);
                run = false;
            }
        }
    }

    
    public void whoStarts ()
    {
        System.out.println("Who starts first? " + name + " or " + CPU_NAME);
        String starter = scanner.nextLine();
        if (starter.toLowerCase().equals(name.toLowerCase()))
        {
            turnName = name;
            whatSymbol();
        }
        else if (starter.toLowerCase().equals(CPU_NAME.toLowerCase()))
        {
            turnName = CPU_NAME;
            whatSymbol();
        }
        else
        {
            System.out.println("Invalid input. try again");
            System.out.println("---------------------------------------------------");
            whoStarts();
        }
    }

    public void startGame()
    {
        System.out.println("Do you want to play the game?");
        String answer = scanner.nextLine();
        switch(answer.toLowerCase())
        {
            case "yes":
                whoStarts();
                break;
            case "no":
                System.out.println("thats too bad. See you next time !!");
                break;
            default:
                System.out.println("Invalid input. try again");
                System.out.println("---------------------------------------------------");
                startGame();
        }

    }
    public void game()
    {
        boolean gameWon = false;
        while(!gameWon)
        {
            int choice = 0;
            System.out.println("---------------------------------------------------");
            printGameBoard();
            System.out.println("Choices : 1 to 9");
            System.out.println(name + "(" + playerSymbol + "): ");
            choice = scanner.nextInt();

            if(turnName.equals(name))
            {
                if(!space[choice - 1])
                {
                    playerTurn(choice);
                    space[choice - 1] = true;
                    turnName = CPU_NAME;
                    gameWon = checkGameStatus();
                }
                else
                {
                    System.out.println("---------------------------------------------------");
                    System.out.println("Occupied Space. Try again.");
                }
                
            }
            if(turnName.equals(CPU_NAME))
            {
                cpuMove();
                gameWon = checkGameStatus();
            }
        }
        
    }

    public boolean checkGameStatus ()
    {
        if(checkWin(playerSymbol))
        {
            System.out.println("---------------------------------------------------");
            System.out.println("Player " + name + " has won!!");
            System.out.println("---------------------------------------------------");
            printGameBoard();
            return true;
        }
        else if (checkWin(cpuSymbol))
        {
            System.out.println("---------------------------------------------------");
            System.out.println("The cpu has won!! you lost");
            System.out.println("---------------------------------------------------");
            printGameBoard();
            return true;
        }
        else if(checkFull())
        {
            System.out.println("---------------------------------------------------");
            System.out.println("The game is tie");
            System.out.println("---------------------------------------------------");
            printGameBoard();
            return true;
        }
        return false;
    }

    public boolean checkWin (String symbol)
    {
        for (int i = 0; i < 6; i += 2)
        {
            if(gameBoard[i][0].equals(symbol) && gameBoard[i][2].equals(symbol)
                && gameBoard[i][4].equals(symbol))
            {
                return true;
            }

            if(gameBoard[0][i].equals(symbol) && gameBoard[2][i].equals(symbol)
                && gameBoard[4][i].equals(symbol))
            {
                return true;
            }
        }

        if(gameBoard[0][0].equals(symbol) && gameBoard[2][2].equals(symbol)
            && gameBoard[4][4].equals(symbol))
        {
            return true;
        }
        if(gameBoard[0][4].equals(symbol) && gameBoard[2][2].equals(symbol) 
            && gameBoard[4][0].equals(symbol))
        {
            return true;
        }
        return false;
    }

    public boolean checkFull ()
    {
        for (boolean spaceFilled : space) {
            if (!spaceFilled) {
                return false; 
            }
        }
        return true;
    }
}
public class Main {
    public static void main(String[] args)
    {

        TicTacToe johnDoe = new TicTacToe("John Doe");
        johnDoe.startGame();
    }
}

New contributor

bruh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật