如图,第二行中的obj难道不是object类的吗?是父类对象啊,为什么可以转换为子类对象(Test)呢?这是第一个问题
if (obj instanceof Test) {
Test other= (Test) obj;
if (this.getBrand()==other.getBrand()&&this.getPrice()==other.getPrice()&&this.getYear()==other.getYear())
return true;
}
return false;
第二个问题:为什么不同类的对象之间的强制转换会报错?