如果父亲是父母,父母是人并且人有父亲,我创建以下内容:
class Person{
Father father;
}
class Parent extends Person{}
class Father extends Parent{}
实例:
Person p1 = new Person();
Person p2 = new Person();
p1.father = p2; //father is of the type Father
这不起作用......现在尝试投射::
Person p1 = new Person();
Person p2 = new Person();
p1.father = (Father)p2;
这也不起作用。
这种情况有什么作用?