java空指针异常如何抛出
1、public static voi蟠校盯昂d main(String[] args){ try{ getNullException(); }catch (NullPointerException e){ System.out.println("捕捉到的异常:" + e.getMessage()); }}public static void getNullException(){ String s = null; try{ s = s.replace("a",""); }catch (Exception e){ throw new NullPointerException(); }}
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:66
阅读量:22
阅读量:73
阅读量:20
阅读量:56