- package cn.CodeSnippet.example;
- public class Test{
- public static void main (String args[]){
- try {
- if (args[0].equals("null")) {
- throw (new NullPointerException());
- } else {
- throw (new ArrayIndexOutOfBoundsException());
- }
- } catch (NullPointerException | ArrayIndexOutOfBoundsException ex) {
- ex.getMessage();
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/171020136475.html
来源: http://www.codesnippet.cn/detail/171020136475.html