Java: Implementation of Interface with Methods passing Interface parameter
问题 I have a given interface called IAbc, which consists of a method with a parameter of interface IXyz. I am not sure whether I should create an attribute IXyz or an attribute XyzImpl in my implementation of IAbc. public interface IXyz { } public class XyzImpl implements IXyz { public void doSomething() { ... } } public interface IAbc { public void setXyz(IXyz val); public IXyz getXyz(); } Implementation 1: public class AbcImpl1 implements IAbc { private XyzImpl attr; public void setXyz(IXyz val