package com.socket.test;
public class TryCatchFinallyReturnTest {
public static void main(String[] args) {
TryCatchFinallyReturnTest bean = new TryCatchFinallyReturnTest();
try{
String reString = bean.test();
Thread.sleep(500);
System.out.println("return String : "+reString);
}catch (Exception e) {
}
}
public String test() throws Exception{
String retString = "start";
try{
System.out.println("start String : "+retString);
retString = "try inner";
throw new Exception("Exception inner");
}catch (Exception e) {
retString = "catch inner";
System.out.println("catch String : "+retString);
return retString;
}finally{
retString = "finally inner";
System.out.println("finally String : "+retString);
return retString;
}
}
}
运行结果:
start String : start
catch String : catch inner
finally String : finally inner
return String : finally inner