/*运行结果:
D:\angel\day10>javac test.java
D:\angel\day10>java Demo
func Finally
main catch
over
*/
class Demo
{
public static void func() throws Exception
{
try
{
throw new Exception();
//System.out.println("func try");//这句话不注释掉会编译失败,因为提示为:无法执行的语句
}
finally
{
System.out.println("func Finally");
}
}
public static void main(String[] args)
{
try
{
func();
System.out.println("main try");
}
catch (Exception e)
{
System.out.println("main catch");
}
System.out.println("over");
}
}
|
|