java中到底什么是继承?

1.何为继承?What is Inheritance?

java中到底什么是继承?

在上图中,对于车来讲,汽车就是子类。对于汽车来讲,奔驰就是子类。车是汽车的基类,超类,或说父类。到底什么是继承?马克-to-win,子类把父类的方法和属性当成自己的一样随便用的这种现象叫继承。In OOP, the ability that subclass inherits all of the variables and methods defined in the superclass is known as Inheritance.

继承是一种“是”的关系,比如汽车是一种车,奔驰是一种汽车。(It represent is-a relationship)
Syntax(语法)
class SubClassName extends SuperClassName{

}


被继承的类叫超类(superclass)。 
继承超类的类叫子类(subclass)。

更多内容请见原文,文章转载自:https://blog.csdn.net/qq_44639795/article/details/103122883

上一篇:eclipse新建Maven Project项目后出现The superclass "javax.servlet.http.HttpServlet" was not found o


下一篇:【原因分析】The superclass "javax.servlet.http.HttpServlet" was not found on the Java Bu