Tag: The his full log int instance string will modify the component
1: A simple example
Public Interface A { void printclassname ();}
Public class Implements A { publicvoid printclassname () { System.out.println ("This is Class b! " ); }}
Public Static void Main (string[] args) { new B (); A.printclassname ();}
Normal output "This is class B"
Interface A is defined in the main function, and the method of interface A is called, but it is important to note that when instantiated, the new is a concrete class that implements the A interface, and when we call the Printclassname method in A, Java goes back to the method in B. What are the advantages of doing this? Is that when we call, we can completely regardless of the subclass of A is how to implement the method in a, only need to call this method, how to implement, we do not care, that is a subclass of things, this is actually a good way to decouple, if we want to modify the other class, just need to change the subclass after new to the good.
2:
What is the use of this mechanism after we know it? In general, the use of more, is the communication and MVP mode
Communication, in fact, is the communication between different components, can be fragment and activity, can also be adapter and activity;
The above we talked about MVP, this model is really important, for the larger project, the significance is far-reaching, can help us to decouple the overwhelmed activity, but also to facilitate our maintenance and expansion;
7: The callback mechanism of Android