使用 Finally 的疑惑,请大家一起讨论!

有以下程序 :

public class FinallyTest   
{  
    public static void main(String args[])  
    {  
        System.out.println("in main return: " + new FinallyTest().getString());  
    }  
      
    public String getString()  
    {  
        String returnString = null;  
        try  
        {  
            returnString = "this string will be return.";  
            return returnString;          
        }finally  
        {             
            System.out.println("execute finally...");  
            System.out.println("before clean returnString's value: " + returnString);  
            returnString = null;  
            System.out.println("after  clean returnString's value: " + returnString);  
            System.out.println("execute finally end.");  
        }         
    }  
} 

 输入出结果是:

execute finally...
before clean returnString's value: this string will be return.
after  clean returnString's value: null
execute finally end.
in main return: this string will be return.

你可能感兴趣的:(finally)