本帖最后由 haohanlinyu 于 2014-6-10 23:01 编辑
package com.itheima;
/*6、 用代码证明,在try中写了return,后面又写了finally,是先执行return还是先执行fianlly?*/
public class Test6
{
public static void main(String[] args) throws Exception
{
Object obj;
sop(firstrun(obj));
}
public static firstrun(Object obj) throws Exception
{
int x=1;
try
{
return x;
}
finally
{
return ++x;
}
}
public static void sop(Object obj)
{
System.out.print(obj);
}
} |
|