instanceof和类型转换
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/8739eaa6ab9d35a1b85ccc0d52b93cb7.jpeg#pic_center)
instanceof
Object object = new Student();
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);
System.out.println("=================================");
Person person = new Student();
System.out.println(person instanceof Student);
System.out.println(person instanceof Person);
System.out.println(person instanceof Object);
System.out.println(person instanceof Teacher);
System.out.println("=================================");
Student student = new Student();
System.out.println(student instanceof Student);
System.out.println(student instanceof Person);
System.out.println(student instanceof Object);
类型转换
package oop;
import oop.demo06.Person;
import oop.demo06.Student;
import oop.demo06.Teacher;
public class Application {
public static void main(String[] args) {
Student student = new Student();
student.go();
Person person = student;
}
}