I am evaluating user inputs as commands for my application. If the user presses Q, or q, and then hits enter, the application quits and execution terminate
Returning all the way back to Returning out of main()
is the cleanest way, of course, but if that's not easy to do, System.exit()
is perfectly fine.
It's not directly relevant to your question, but throwing an (unhandled) exception is usually the way to terminate on a fatal condition, since it provides a lot of tracing info to the poor user.