有关于异常的一个小练习 help me

定义一个学生类,类中有一个年龄(age)属性,写一个设置年龄的方法,年龄大于18岁,抛出”年龄不能大于18”的异常方法需要声明一下我有异常抛出啊,调用者你要捕获它


public class Student{
    private int age;

    public void setAge(int age){
        if (age > 18){
            throw new RuntimeException("年龄不能大于18");
        }
        this.age = age;
    }
}