-
-
把子类转换成父类,向上转型
-
-
方便方法的调用
封装 继承 多态
import Dome.Person;
import Dome.Student;
import Dome.Teacher;
?
public class Application {
public static void main(String[] args) {
Person obj = new Student();
((Student)obj).go();
}
}
package Dome;
?
public class Teacher extends Person{
}
?
?
?
?
?
?
?
?
?
?
?
?
/*
public static void main(String[] args) {
?
Object object = new Object();
System.out.println(object instanceof Student);
System.out.println(object instanceof Person);
System.out.println(object instanceof Object);
System.out.println(object instanceof Teacher);
System.out.println(object instanceof String);
?
*/