I have a guessing program, and Im trying to add a counter. In the bolded parts I have a counter. When you get a guess wrong, it adds 1 to the counter. But when it prints it, it just prints as 0 no matter what.
                    public static void firstGame(String Answer, String userGuess, int counter)
                {
                    userInput = new Scanner(System.in);
                    boolean playgame = true;
                    while(playgame == true)
                    {
                    Answer = "Sam";
                    lnPrint(" ");
                    lnPrint("Take a guess at my name! It starts with an S...");
                    sPrint(":");
                    userGuess = userInput.next();
                    if(userGuess.equalsIgnoreCase(Answer))
                        {
                            lnPrint("You got it! Its " + Answer);
                            lnPrint(" ");
                            break;
                        }
                    else if(userGuess != Answer)
                        {
                            lnPrint("Good guess, keep trying!");
                            counter++;
                        }
                    }
                }
That is my game method with the counter.
public static void main(String[] args)
    {
        Scanner userInput = new Scanner(System.in);
        int Start, counter = 0;
        String Answer, userGuess, middleAnswer, middleUserGuess;
        Answer = null;
        userGuess = null;
        middleAnswer = null;
        middleUserGuess = null;
        Start = 0;
            while(Start !=2)
            {
            lnPrint("(1) Start Game");
            lnPrint("(2) Exit");
            sPrint(":");
            Start = userInput.nextInt();
                if(Start == 1)
                    {
                        firstGame(userGuess, Answer, counter);
                        lnPrint("Now, how about my middle name?");
                        nlnPrint(counter);
                        middleGame(middleAnswer, middleUserGuess);
                    }
This is the code that prints it
 
     
     
    