I believe I'm not formatting the System.exit() method properly. This is how its formatted in my program:
else if (input==6){
System.exit();
}
Is this correct syntax?
I believe I'm not formatting the System.exit() method properly. This is how its formatted in my program:
else if (input==6){
System.exit();
}
Is this correct syntax?
System.exit(int status)
takes an int
parameter. The status is not especially important; it's more of a feedback for the System
if the exit
went well. It's not important in Java; it's just something inherited by Java from older programming languages.
Just for your reference:
0 = fine
anything else = represent different codes
I would suggest using System.exit(0);
System.exit(int) takes an integer argument, but otherwise you can call it to terminate your program.
Why do you want to call your
main()
method again? It is normally the static entry point to your program. If there's some code you wish to repeat, I'd suggest putting this in its own method and calling that (frommain()
and your code in the question).