public class GraduateStudent extends Student {
    public static void main(String[] args) {
        Student s = new GraduateStudent();                // 向上造型
        GraduateStudent g = (GraduateStudent) s;           // 向下造型
        GraduateStudent g = new Student();                // 错误，不兼容的类型
        if (s instanceof GraduateStudent)                  // 判断是子类的实例之后再造型
            g = (GraduateStudent) s;
    }
}
