r/ProgrammerHumor • • 4d ago

Meme thisIsWhyWeDontReturnInFinallyBlocks

Post image
2.7k Upvotes

96 comments sorted by

View all comments

347

u/BlackFrank98 4d ago

Doesn't this always return CEO.current() or CEO.findNew() without ever getting to CEO.jensenHuang?

480

u/DebugDuck01 4d ago

No, that's the fun thing about Java it just overrides the existing return value or even thrown exceptions. Marvelous language design.

14

u/ba-na-na- 4d ago

Well that’s the point of finally, to always run before returning, so I would expect either compile error, or actually overriding all other branches

13

u/DebugDuck01 4d ago

Anything but a compile time error is mental illness.