scope - Java - If I return in a catch block, will the finally block be executed? -
this question has answer here:
- does execute in java? 41 answers
this i'm trying do:
try { //code } catch (exception e) { return false; } { //close resources }
will work? bad practice? better doing this:
boolean inserted = true; try { //code } catch (exception e) { inserted = false; } { //close resources } return inserted;
yes, will. things can prevent block execute (afair) system.exit()
, , infinite loop (and jvm crash, of course).
Comments
Post a Comment