Assume that I want to exit a console program if the user entered the char f, and in any time of the program.
The user is supposed to enter some info but I want for each step he entering the input to be able to stop all the operation if he entered “f”?
How can I do that?
Should it be something like:
try
{
if (userchoice.equals("F"))
{
throw new exception e;
}
}
catch (exception e)
{
System.exit(1);
}
Thanks
Here’s the correct syntax: