Does a break leave just the try/catch or the surrounding loop?

后端 未结 6 874
花落未央
花落未央 2020-12-29 01:28

If I have a try ... catch block inside a while loop, and there#s a break inside the catch, does program execution leave t

6条回答
  •  误落风尘
    2020-12-29 02:05

    Will an exception thrown in doStuff() exit the loop?

    Step by step, here is what will happen:

    1. The exception is thrown in doStuff()
    2. Your "eat all Exceptions" handler will catch the exception.
    3. The "break" statement will leave the while loop.

提交回复
热议问题