Most voted "try-finally" questions
12 questions
Sort by count of
-
46
votes2
answers11298
viewsHow does Try-with-Resources work?
In Java 7, the concept of Try-with-Resources was added in the language. What is the Try-with-Resources? How does it work? What does it serve? How is it used? What problem does it aim to solve?…
java exception try-catch try-finally try-with-resourcesasked 7 years, 11 months ago Victor Stafusa 63,338 -
27
votes6
answers8712
viewsHow and when to use Finally after a Try?
First I would like to know why in using the finally What are its advantages? It really only serves for when an exit occurs from within the scope of a block try-catch, as when some return or goto…
-
13
votes2
answers869
viewsWhat is Finally for in PHP 5.5?
PHP 5.5 implemented a feature (which I’ve heard exists in other languages) called finally, in the handling of exceptions (together with the try/catch) We have the following example:…
-
9
votes3
answers4676
viewsIs the Finally block always run in Java?
In this code there is a block of Try/catch with a Return within it. try { alguma_coisa(); return successo; } catch (Exception e) { return falha; } finally { System.out.println("Eu não sei se será…
-
6
votes1
answer1441
viewsExecution flow of a Try/catch/Finally block
How the execution flow works in a block try/catch/finally in the example below? public class ExceptionTest { public static void makeException() throws ExceptionAlpha, ExceptionBeta, ExceptionGamma {…
-
4
votes2
answers360
viewsPut method return before a "Finally" block
Considering: try { System.out.println("Parte 1"); return false; } finally { System.out.println("Parte 2"); } What will be the output and what happens behind the scenes so that the output come out…
-
3
votes1
answer143
viewsHow to not include Finally and still close IO Streams, Connections, Statements, and other Resources?
We know the need to close resources (files, connections, also called Resources) consumed in Java, such as OutputStream and InputStream. When we don’t close them, we create performance problems and…
-
2
votes1
answer853
viewsCan the use of Try in Delphi when misused be a trap?
Once a programmer saw my codes and praised me for making use of Try, I confess that I was not thrilled by the praise for finding that the use of Try is not a simple way to solve exceptions, I see…
-
2
votes1
answer57
viewsJava 8 SE: Finally block of a method is running before entering the method
On page 359 of the Book: Java - How to Program - 10th Edition. Deitel explains the treatment of Java exceptions. It exemplifies the question with the following code: public class UsingExceptions {…
-
1
votes0
answers252
viewsIf or Try/Catch?
here at work I came across a code that deals error in an if instead of Try/Catch. The programmer justifies that the catch interrupts the code, but I believe that a Finally ensures the execution. Can…
-
-1
votes1
answer180
viewsWhat is the difference between the ending, Finally and finish in Java?
What is the difference between the terms: final, finally and finalize(), in the programming language Java?
-
-1
votes1
answer222
viewsPut except with bug name in python
I need to create a Try except, with two excepts, but do not know how to put the specific error in the first except, the error that appears this below, someone could help me? raise…