Terminating a Java Program

后端 未结 7 2028
感动是毒
感动是毒 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:20

    System.exit() terminates the JVM. Nothing after System.exit() is executed. Return is generally used for exiting a method. If the return type is void, then you could use return; But I don't think is a good practice to do it in the main method. You don't have to do anything for terminate a program, unless infinite loop or some strange other execution flows.

提交回复
热议问题