+ 1

Can we write more than one finally in java

java

19th Jun 2017, 3:17 AM
Ashutosh Sinha
Ashutosh Sinha - avatar
3 Answers
+ 5
No. There can only be one finally block per try/catch. If you need to do something different for each error (or for the lack of error), you'll have to write it in the try (no error) or catch(es).
19th Jun 2017, 3:42 AM
Tamra
Tamra - avatar
+ 5
Right, one finally for every try/catch.
19th Jun 2017, 7:02 AM
Tamra
Tamra - avatar
+ 1
but if we use multiple try catch in one program, then we can use multiple finally ?
19th Jun 2017, 6:56 AM
Ashutosh Sinha
Ashutosh Sinha - avatar