0

Can it be only try block ?

Done some research and found out that try + finally is used but can't find info on only try block. Is it possible to compile ?

18th Jun 2020, 6:23 PM
Bartek O.
Bartek O. - avatar
2 Réponses
+ 3
Bartek O. Yes it is possible to have try block without catch and finally block. Compiler will never give any error and program will run successfully but you can't handle exception and nullify the objects which is very important.
18th Jun 2020, 7:21 PM
A͢J
A͢J - avatar
+ 1
Finally is not mandatory, update: In C# even catch is not mandatory. But you can catch the most generic error cases and leave the branch empty.
18th Jun 2020, 7:00 PM
Sandra Meyer
Sandra Meyer - avatar