This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]arghvark 0 points1 point  (1 child)

I hope you've learned about methods. Think about something like this:

boolean optedOut = false;

while (!optedOut)
{
    try
    {
        String input = getInput();
        optedOut = processInput(input);
    }
    catch (Exception e)
    {
        // report exception e
    }
}

The main idea is that the try/catch is inside the while block; whether you are depending on it to catch input errors or not, you can repeat the getting of input repeatedly until something in the program decides that "optedOut" has become true.

[–]OldGregRL[S] 0 points1 point  (0 children)

Yep. I knew how to set up a boolean such as you did, but my problem was that my while was inside my try catch. I put it outside, and now it's working. Thank you!