java的异常处理

架构:java的异常处理是一种你丢我捡的架构  处理方法:在该方法加上异常处理语句来处理,另外一种是把异常交给另外的方法来处理

异常的实例对象throwble类: error和exception 前者无法处理,程序直接终止运行,后者异常可以采取措施处理

exception类:arithmeticexception 数学运算产生的错误,例如除以0  ;arrayindexoutofboundsexception 数组索引小于0或者是超出数组边界产生的异常;arraystoreexception 保存数组的类型不符合;illegalargumentexception 方法调用时参数类型不符产生的异常; nullpointexception对象值为nul产生的异常

异常处理语句:try{}catch(exception e){}finally{}

try{}catch{**}{**}catch(**){**}finally{}同时处理多种异常

抛出异常:throw new ArithmeticException("");

自定义异常:class userexception extends Exception{****public String getMessage(){}}

posted @ 2016-05-05 21:01  风雨缠舟  阅读(126)  评论(0编辑  收藏  举报