1.结论:
- 子类 instanceof 父类 == true
- 父类 instanceof 子类 == false
2.测试代码
@Test
public void testInstanceof() {
// 子类 instanceof 父类
ConsultSmsPatientDataBO sub = new ConsultSmsPatientDataBO();
boolean one = sub instanceof ConsultSmsDataBO; // one = true
// 父类 instanceof 子类
ConsultSmsDataBO par = new ConsultSmsDataBO();
boolean two = par instanceof ConsultSmsPatientDataBO; // two = false
}