instanceof 判断两者是否有继承关系
调用类
package Demo04;
public class Application {
public static void main(String[] args) {
//instanceof 一条线的线性指向关系,在这条线的为true
//主要与左边的类型有关,右边为指向关系
//Object>Person>Student || Teacher
Student student = new Student();
System.out.println(student instanceof Student);//true
System.out.println(student instanceof Person);//true
System.out.println(student instanceof Object);//true
//System.out.println(student instanceof Teacher);//编译错误
//Studnet 与 Teacher 为同类
System.out.println("====================&