Practice ยท 3 of 3
The finally audit log
Write tryResource(boolean fail) that appends to a StringBuilder exactly: "open;" always; then, if fail is true, throw IllegalStateException; otherwise append "work;" then "close;". Add "catch;" in a catch block and "finally;" in a finally block. Return the log **once, at the very end** - after the finally block (a return inside try/catch escapes before finally can append).
Difficulty: advanced
Press Submit to check your solution.
Back to lesson: Practice: Practice: Fail Well