try{ //要检查的代码 } catch(Exception e){ //如果上面出现,处理异常 } finally{ //怎么都执行的代码块 } throw new Exception("mes");//抛出自定义异常