The exception will proceed immediately to the next frame in the call stack, if not caught. It also provides a possibility to carry a potential return value. Finally, I am writing a second helper method which utilizes the forEach helper:
The helper simply calculates whether the first Object is followed by the second one in the collection (irrespective whether this makes sense on a plain Collection; it is just to illustrate the usage). The forEach method is called with an anonymous inner class, which is the rough analogue to a closure. The non-local return is simulated with the NonLocalReturn Exception. When the Exception is thrown, control flow immediately is propagated from the transform method to the followOn method without any further execution within the forEach method. This non-local return might easily break code in forEach, as indicated by the comments there. If, prior to calling transform a resource is opened which must be closed before returning from the method, the client code broke the API code with a non-local return.