use*_*724 -1 java design-patterns dependency-injection interface class
朋友们,我在Java中遇到了一个问题:我想实现一个结构,但是我遇到了一些困难,任何人都可以帮助我.
interface samp1{
method1()
method2()
method3()
}
interface samp2{
method4()
method5()
}
class Samp implements samp1,samp2
{
// this class needs only method1 from interface samp1 and method 4 from interface samp2
// I don't want to override all the methods from interface
}
Run Code Online (Sandbox Code Playgroud)
谁能为此提出一些解决方案?
有没有可用的设计模式?如果是,请提供参考链接.
提前致谢.
接口是合同.它说"我的类实现了所有这些方法".
请参阅:http://docs.oracle.com/javase/tutorial/java/concepts/interface.html
如果您不想这样,请不要使用接口.