代码如下:
public class Test1
{
public static void main(String[] args)
{
C c = new C();
try
{
c.getExcC();
}catch(Exception e)
{
System.out.println(e.getClass().getName());
}
}
}
class Aexception extends Exception
{
}
class Bexception extends Exception
{
}
class C
{
public void getExcA() throws Aexception
{
throw new Aexception();
}
public void getExcB() throws Bexception
{
throw new Bexception();
}
public void getExcC() throws Exception
{
try
{
getExcA();
}finally
{
getExcB();
}
}
}
输出为:
Bexception