How can I exit a Java program without System.exit?(From User Input?)

前端 未结 1 537
闹比i
闹比i 2021-01-06 10:50

Here is my code. I am not sure how to exit the program using a return value. Any ideas? THis is the last step from my assignment. Important areas are marked with /////// I h

相关标签:
1条回答
  • 2021-01-06 11:35

    As long as you don't need to return custom exit code (other than 0, as returned by System.exit(0)) and don't start new threads, you can terminate your program by doing

    return; 
    

    in your main() method. Note that there is no value returned, so that you don't need to change your main() method from void to int.

    0 讨论(0)
提交回复
热议问题