在我的视图中遵循Java中的基本示例,子类型和继承是相关的。
public class A extends B implements C{.....}
public interface D {......}
public interface C extends D {......}
C c = new A(); // I thinks this is subtyping
B b= new A(); // because A inherits B and can also referred as subtyping
D d= new A(); // because D is a superinterface and it is also referred as subtyping
那么,实际"是" 的子类型和"继承自" 的不同之处是什么?我发现它们是相关的,我认为继承是Subtyping的一个子集。但在许多文章中我都注意到它们之间存在一些差异。虽然我没有得到任何明确的想法。
编辑: - 这些问题指出了私有案例和受保护案例之间重写方法的差异。在我的问题中,我强调了Subtypes与继承。