Recently written Android applicationsProgramThey are all Java programming ideas. They are different from C ++, mainly in inheritance. The extends and implements are understood as follows:
1. extends is a subclass that inherits the keywords of the parent class. After inheriting the parent class, you can use the parent class method or rewrite the parent class method.
Implements is a class that implements one or more interfaces. The method of the interface is generally empty, and I understood it as a pure virtual function before doing C ++. You need to re-write the method to use it.
If implements is an interface, all methods of this interface must be implemented.
2. Different from C ++, Java does not support multiple inheritance, but can be implemented using interfaces. That is to say, extends can only inherit one class, while implements can implement one or more interfaces.
Example: Class Child extends parents implements method interfacea, interfaceb. interfacec
Note that interfaces and interfaces can be inherited directly by extends.
For example:
Public Interface Uinterface { Void Ondevicerun ( Int ID );} Interface Pinterface Extends Uinterface { Void Onotherrun ();} Class Example Implements Pinterface { Void Ondevicerun ( Int ID) {system. Out. println (ID + "Pinterface" );} Void Onotherrun () {system. Out. println ( "Onotherrun" );}}