1. Abstract level: General class, abstract class-interface
Ordinary class : is the class that we commonly use;
Abstract class : specifically used to inherit the quilt class, mainly in order to conform to the real world law
such as: Animal class: (Every real object has a class relative to it, but otherwise, some code classes do not exist in the real world, because animals are just a generic term for a class of objects, not an individual called an animal)
So, the abstract class and its subclasses can be understood as a family, and they all have many of the same properties
Interfaces : You can implement the same behavior for unrelated classes without having to consider the hierarchical relationships of those classes. ( special abstract class, higher level than ordinary abstract class )
2. Inheritance and implementation (whatever is used for inheritanceextends, and the implementation only usesImplements) 2.1. ClassInheritanceClassextendsCan inherit only one parent class, single inheritance)
Eg: public class Student extends person{//Here person is a normal class,
to implement multiple inheritance in//java, you have to use interfaces to implement them indirectly.
}
2.2. ClassImplementInterfaceImplements, a class can implement multiple interfaces)
Eg: public class Student implements runnable{//Here Runnable as an interface
}
2.3. InterfaceInheritanceInterfaceextends, interfaces can inherit multiple interfaces)
Eg: public class flyable extends runnable,eatable{//runnable,eatable Here are interfaces, multiple interfaces separated by commas
}
Summary:1. In order to represent the particularity of the interface , the definition is no longer used in class, but instead changed to interface(in fact, a class, a special abstract class)
2. only when the class implements the interface is special, the use of implements (Implementation), the other conditions are used extends (inheritance)
Simple comprehension and summary of Java interface