1. The introduction and creation of the interface
Keywords: interface
2, the reference and specifications of the interface
Keywords: Implements
Interface: A member attribute is all abstract special abstract categories , have the same normative role in the program
1. All methods in the class are abstract methods
2. There is no need to add abstract
before abstract methods. 3. The attributes of interface abstract methods are public
4. Member attributes must be Abstract for constants
:
1. There is at least one abstract method in the class
2. Abstract
must be added before the abstract method. Common points:
1. Neither of them can be instantiated. , must be inherited or referenced
2. After inheritance or reference, all abstract methods need to be overloaded before use
Interface has its own creation keyword: interface is similar to the creation of ordinary classes
interface demo {
const NAME="name";
function Fun1();//Object methods are all abstract methods, no need to add adstract
in front function Fun2();
}
interface You can use the keyword: implements to separate multiple references with commas.
1. Common class reference interface examples:
class mypc implements demo, demo2, demo3{
…
}
2. Examples of abstract class reference interfaces:
abstract class mypc implements demo, demo2, demo3{
…
}
3. Examples of coexistence of inherited parent class reference interfaces:
class mypc extends root implements demo , demo2 , demo3{
…
}
4. Interface and interface inheritance:
interface demo3 extends demo{
…
}