Android——Summary of small knowledge points

(1)stub

What are stubs?

  • If an interface has many methods, if you want to implement this interface, you must implement all the methods.
  • In terms of business, a class may only need one or two methods. If you directly implement this interface, in addition to implementing the required methods, you must also implement all other unrelated methods. And if the interface is implemented by inheriting the stub class, this trouble is avoided.

for example:

  • interface class
public interface IRepo {
    
    
    public void remove(String... sarr);

    public void add(String... sarr);

    //Lots of other methods I don't need now
}
  • stub class:
public class Repo extend IRepo.Stub {
    
    
    @Overread
    public void add(String... sarr) {
    
    
    }
}

Guess you like

Origin blog.csdn.net/ly0724ok/article/details/121082876