编写一个能抛出并捕获、处理NullPointerException、NumberFormanException多异常的程序
我的理解是类似于有一个异常过滤器,拦截程序中所有发生的异常,统一处理
------解决方案--------------------------------------------------------
在下层不管什么方法都声明抛出Exception,在最上层调用的时候进行异常捕获
try
{
}
catch(Exception e)
{
if(e instanceof NullPointerException)
{
处理。。。。
}
if(e instanceof NumberFormanException)
{
处理。。。。
}
}
------解决方案--------------------------------------------------------
做一个拦截器,对所有发生异常的地方处理
------解决方案--------------------------------------------------------
以考struts的异常处理