I made some command line games and at the end of the game I want to ask if the player wants to play again. You can see in the code how I made but it's not working and I don't know why.
Can anybody help me?
import java.util.Scanner;
//WIP
public class GuessingGame2 {
    static Scanner userInput = new Scanner(System.in);
    static int randNumber;
    static int guessNumber;
    static boolean gameStatus;
    static void checkNum(int x) {
        guessNumber++;
        if(x == randNumber) {
            gameStatus = true;
        } else if(x < randNumber) {
            System.out.println("Too small!");
        } else {
            System.out.println("Too big!");
        }       
    }
    static void checkAnsw() {
        if(userInput.hasNextLine()) {
            if(userInput.nextLine() == "Y" || userInput.nextLine() == "y") {
                guessGame();
            } else if(userInput.nextLine() == "N" || userInput.nextLine() == "n") {
            } else {
                System.out.print("Y or N ");
                checkAnsw();
            }
        } else {
            System.out.print("Y or N ");
            userInput.next();
            checkAnsw();
        }
    }
    static void guessGame() {
        randNumber = (int) (Math.random() * 1000);
        guessNumber = 0;
        gameStatus = false;
        System.out.println("Try to guess a number from 1 to 1000!");
        while(gameStatus == false) {
            System.out.print("Your guess: ");
            if(userInput.hasNextInt()) {
                checkNum(userInput.nextInt());
            } else {
                System.out.println("You need to choose a number!");
                userInput.next();
            }
        }
        System.out.println("You guessed the number in " + guessNumber + "  tries.");
        System.out.print("Do you want to play again? Y or N ");
        checkAnsw();
    }
    public static void main(String[] args) {
        guessGame();
    }
}
 
     
     
    