Terminating a Java Program

后端 未结 7 2030
感动是毒
感动是毒 2020-11-27 12:03

I found out ways to terminate (shut-down or stop) my Java programs. I found two solutions for it.

  1. using return;
    When I want to quit or

7条回答
  •  不知归路
    2020-11-27 12:29

    So return; does not really terminate your java program, it only terminates your java function (void). Because in your case the function is the main function of your application, return; will also terminate the application. But the return; in your example is useless, because the function will terminate directly after this return anyway...

    The System.exit() will completly terminate your program and it will close any open window.

提交回复
热议问题