异常处理(throw,throws) 1、关键字throws1.1、通常设在方法中使用语法public void readFile(String path) throws IOException, FileNotFoundException2、关键字throw2、1通常设在判断语句中语法如下if (age 0 || age 150) { // 主动抛出异常 throw new IllegalArgumentException(年龄必须在0-150之间当前值 age); }2.2手写异常通常有两步组成1使用异常类去继承Exception(2)创建有参和无参的构造方法有参构造方法使用super关键字。2.3.例子public static void checkStudents(Student student) throws AgeException{ if (student.getAge()6|student.getAge()12) { throw new AgeException(年龄必须在6-12岁);} }