The Exception class will collect garbage when there are no more references to it, and the garbage collector eventually accepts the queue. An exception object is processed like any other object allocated on the heap.
Since the exception object pops up, it will no longer reference it when there are no more methods that catch or throw it above the stack.
Both examples will have the same effect, since none of them throws an exception above, it will exit the link when the method returns.
source share