Stop executing further code in Java

后端 未结 6 2052
失恋的感觉
失恋的感觉 2021-01-01 16:25

I have looked in the Javadoc but couldn\'t find information related to this.

I want the application to stop executing a method if code in that method tells it to do

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-01 17:11

    Either return; from the method early, or throw an exception.

    There is no other way to prevent further code from being executed short of exiting the process completely.

提交回复
热议问题