Java exception
2008-05-26 20:32
190 查看
Java exception :
package com;
public class Test ...{
public static void main(String[] args) ...{
try ...{
throw new NullPointerException();
//System.out.println("Exception:"); // unreachable
} catch (NullPointerException ex) ...{
System.out.println("Exception:");
System.out.println(ex.getMessage());
}
try ...{
exceptionOne();
} catch (NullPointerException ex) ...{
System.out.println("exceptionOne:");
System.out.println(ex.getMessage());
}
try ...{
exceptionTwo();
} catch (NullPointerException ex) ...{
System.out.println("exceptionTwo:");
System.out.println(ex.getMessage());
}
// exceptionOne(); // exit main and program terminate
}
private static void exceptionOne() ...{
throw new NullPointerException();
//System.out.println("Exception:"); // unreachable
}
private static void exceptionTwo() ...{
if (true) ...{
System.out.println("ex2");
throw new NullPointerException();
}
}
}
Exception:
null
exceptionOne:
null
ex2
exceptionTwo:
null
相关文章推荐
- java exception处理心得
- java EXception
- JAVA Exception 和 Error 的理解
- java exception
- java Exception
- Java Exception 捕获和显示实例详解
- Java Exception处理之最佳实践
- JAVA Exception异常总结(JAVA Exception面试笔试总结)
- Java Exception
- Java Exception 捕获和展示
- java exception 和 runtimeException的区别
- Java Exception和Error的差别
- JAVA Exception
- Java Exception
- Java Exception 之 try catch finally
- Java Exception处理之最佳实践
- Java Exception
- Java Exception
- java exception
- Java Exception系列一:关于throws和throw