【1】why Java接口作为参数传递
https://stackoverflow.com/questions/2575429/interface-as-a-method-parameter-in-java
There are many examples in the Java standard API, especially in the collections framework. For example, Collections.sort() can sort anything that implements the List interface (not just ArrayList or LinkedList, though implementing your own List is uncommon) and whose contents implement the Comparable interface (not just String or the numerical wrapper classes - and having your own class implement Comparable for that purpose is quite common).
It's not the interface "object" being passed to the method, still just a regular object. It's just a way of saying "this parameter will accept any object that supports this interface". It's equivalent to accepting some object of a base class type, even if you're passing in a subclass.
标签:own,Feb,just,object,2th,interface,Java From: https://www.cnblogs.com/YeYangzhi/p/17087663.html