object reference set to null in finally block
问题 public void testFinally(){ System.out.println(setOne().toString()); } protected StringBuilder setOne(){ StringBuilder builder=new StringBuilder(); try{ builder.append("Cool"); return builder.append("Return"); }finally{ builder=null; /* ;) */ } } why output is CoolReturn, not null? Regards, Mahendra Athneria 回答1: The expression is evaluated to a value in the return statement, and that's the value which will be returned. The finally block is executed after the expression evaluation part of the