1. Introduction and creation of interface
Keywords: interface
2. Reference and specification of interface
Keywords: implements
Interface: A special abstract class in which member attributes are all abstract, the same as canonical function in a program
1, the class is all abstract method
2, the abstract method without adding abstract before
3. Interface Abstract Method property is public
4, member property must be constant
Abstract:
1. There is at least one abstract method in the class
2, the abstract method needs to add abstract before
Common:
1, itself can not be instantiated, must be inherited or referenced
2. After inheriting or referencing, all abstract methods need to be overloaded before they can be used
Interfaces have their own creation keywords: interface is similar to common class creation
Copy Code code as follows:
Interface Demo {
Const name= "name";
function Fun1 ()//object method All is abstract method, front need not add adstract
function Fun2 ();
}
Interfaces can use keywords: implements multiple references and separate them with commas.
1, Common class reference interface examples:
Copy Code code as follows:
Class MyPC implements demo, Demo2, demo3{
......
}
2, abstract class Reference interface example:
Copy Code code as follows:
Abstract class MyPC implements demo, Demo2, demo3{
......
}
3, inherit the parent class reference interface Coexistence Example:
Copy Code code as follows:
Class MyPC extends Root implements demo, Demo2, demo3{
......
}
4, interface and interface inheritance:
Copy Code code as follows:
Interface Demo3 extends demo{
......
}