Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [finally]

The finally block always executes after a try block, regardless of how the control exits the block.

Filter by
Sorted by
Tagged with
-1 votes
5 answers
4k views

Finally block when no exceptions thrown

I'm doing some cleanup operations that could throw an exception, and I want to implement the logic of a finally block, but only if no exceptions are thrown: The initial implementation is this: ...
thecoop's user avatar
  • 539
2 votes
1 answer
531 views

Event subscription in finally clause

Background My program communicates with a device that is usually asynchronous, but can sometimes behave synchronously. I have an event handler that I use for receiving the data asynchronously, then I ...
Snoop's user avatar
  • 2,738
8 votes
2 answers
6k views

How to get around non-initialized objects in the `finally` block?

I like using final variables whenever possible. Often those variables have to be closed afterwards. Note that I'm currently working on Java 6 so there is not closeable interface, but the same applies ...
rath's user avatar
  • 886
12 votes
5 answers
2k views

What is the conceptual difference between finally and a destructor?

First, I am well aware of Why is there no 'finally' construct in C++? but a lengthy-growing comment discussion on another question seems to warrant a separate question. Apart from the issue ...
Martin Ba's user avatar
  • 7,607
2 votes
1 answer
504 views

Which programming language first came up with the finally block?

Which programming language first came up with the finally block? I ask purely out of curiosity. It is a very useful piece of syntactic sugar, and whoever first created it surely has a very ...
patstuart's user avatar
  • 643