Brad Dwan wrote:Generally the finally block shouldn't be used except for "safety-net" situations. You should never rely on them to do their job for there is no guarantee that they will execute.
Hi Brad,
I think you're thinking of overriding the finalize() method, which is, as you say, not guaranteed to be executed. finally blocks, on the other hand, will
always be executed after the corresponding try, with the single exception being that the finally block won't execute if the JVM exits (via System.exit() or a crash) during the try. That's an iron-clad guarantee.