When the program calls the getValidString it won't display "Judge Another? (y/n)"
It seems like everything should work I just can't figure it out

//see if the user would like to continue
choice = getValidString(sc,"Judge Another? (y/n): ", "y" , "n" );


private static String getValidString(Scanner sc, String prompt, String s1, String s2)
{
    String s = "";
    boolean isValid = false;
    while(isValid ==false)
    {
        s = getString(sc,prompt);
        if(s.equalsIgnoreCase("y") || s.equalsIgnoreCase("n"))
        {
            isValid = true;
        }//end if
        else
        {
            System.out.println("Error! Please enter '" + s1 + "' or'" + s2 + "'.");
        }//end else
    }//end while
    return s;
}//end getValidString

private static String getString(Scanner sc, String prompt)
{
    String s = "";
    boolean isValid = false;
    while (isValid == false);
    {
        System.out.print(prompt);
        s = sc.nextLine();
        if (s.equals(""))

            System.out.println("Error! Entry Required.");

        else

            isValid = true;

    }//end while
    return s;
}//end getString

Edited 3 Years Ago by Dani: Formatting fixed

What - that you can't post in code tags?

i dont know where to put the validation when i ask the user to continue

No, as I tried to explain, your problem is that you don't know how to start a new thread rather than interrupting someone else's. To help you out: http://tinyurl.com/yzgjk68 . Go do that and click on the first link. Read carefully.

Edited 7 Years Ago by BestJewSinceJC: n/a

No, as I tried to explain, your problem is that you don't know how to start a new thread rather than interrupting someone else's.

let me delete my posts and ill start a new thread.

ive created a new thread called string validation help 2. if you dont mind, can you please go to it and help me?

Edited 7 Years Ago by El Duderino: n/a

This article has been dead for over six months. Start a new discussion instead.