Assigning null to variable in finally block [duplicate]
问题 This question already has answers here : Does a finally block always get executed in Java? (47 answers) Closed 5 years ago . The output of the following piece of code is "Test Passed"; can someone explain to me why ? public class Test { public static void main(String args[]) { System.out.println(new Test().print()); } protected StringBuilder print() { StringBuilder builder = new StringBuilder(); try { builder.append("Test "); return builder.append("Passed!!!"); } finally { builder = null; } }