關於try catch finally的一段測試代碼

import java.io.File;


public class Mian {

	
	
static String 	f()
	{
	
		try {
			File  f=new  File("ss");
			
			
			f.exists();
			
			return  s();
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		finally
		{
			
			
			System.out.println("finally");
			return "finally return  value";
			
		}
		
		
	}

static  String  s()
{
	System.out.println("not finally executed");
	
	return  "not finally";
	
}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	System.out.println(	f());
		
	}

}
 
發佈了35 篇原創文章 · 獲贊 0 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章